Menu
Topics Index
...
`

Search data2483


If you need explanation Read this topic

If you need Answer Take test on this topic

Search data2483
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) {
        data = "songs";
        Search input = new Search();
        Class cls = input.getClass();
        Field folder;
        try {
            folder = cls.getField(data);
            System.out.println(folder);
        } catch (NoSuchFieldException e) {
            System.out.println("No Such Field Exception");
        }
    }
}

A. public static java.lang.String Search.songs
B. No Such Field Exception
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.

B.is the answer.as  exception ariases...and the catch blocks prints it.

Posted by Shabaaz Shaikz    2014-03-24 13:10:59


ans is C because there is no exception with named NoSuchFieldException in throwable

Posted by Adithya Aleti    2014-03-24 13:26:31


in print(folder)// here folder is not a string type
so here compilation error occur
ans : c
compilation error

Posted by Ananda Kumar    2014-03-24 13:36:28


Congratulations Shabaaz Shaikz. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-03-25 04:52:25


© meritcampus 2019

All Rights Reserved.

Open In App