Menu
Topics Index
...
`

Search data


If you need explanation Read this topic

If you need Answer Take test on this topic

Search data
What will be the output of the following program?
import java.lang.reflect.*;
public class Search {
    public static String data;
    public static void main(String[] args) throws NoSuchFieldException {
        data = "songs";
        Search input = new Search();
        Class cls = input.getClass();
        Field folder = cls.getField("data");
        System.out.println(folder);
    }
}

A. java.lang.String Search
B. public static java.lang.String Search.data
C. Compilation Error
D. Runtime Error
Topic: Advanced Java Programming Concepts

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

Ans is B.

Posted by Sagar Kamble    2014-02-12 12:57:32


ans:B

Posted by Bharath Yelchuri    2014-02-12 13:02:35


ans B  getClass returns runtime class of an object and getField returns field object

Posted by Bheema Reddy    2014-02-12 13:14:34


No Winner for this dose. Correct option is B. Bheema Reddy already won the dose.

Posted by Merit Campus    2014-02-13 04:13:00


© meritcampus 2019

All Rights Reserved.

Open In App