Home » JAVA Programming » Networking » Question
  1. What is the output of this program?
     import java.lang.reflect.*;
    public class Additional_packages_Example
    {
    public static void main(String args[])
    {
    try
    {
    Class obj = Class.forName("java.awt.Dimension");
    Field fields[] = obj.getFields();
    for (int k = 0; k < fields.length; k++)
    System.out.println(fields[k]);
    }
    catch (Exception e)
    {
    System.out.print("Exception");
    }
    }
    }
    1. Program prints all the methods of ‘java.awt.Dimension’ package
    2. Program prints all the data members of ‘java.awt.Dimension’ package
    3. program prints all the methods and data member of ‘java.awt.Dimension’ package
    4. Program prints all the constructors of ‘java.awt.Dimension’ package
    5. None of these
Correct Option: B

Program prints all the data members of ‘java.awt.Dimension’ package



Your comments will be displayed only after manual approval.