Menu
Question Index
...

What will be the output of the following program?

import java.lang.reflect.*;
public class Search {
    public static void main(String[] args) {
        String 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");
        }
    }
}


java.lang.String Search
public static java.lang.String Search.data
No Such Field Exception
Compilation Error
Runtime Error

Doubts

Problems

Topic: Advanced Java Programming Concepts

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App