Home » JAVA Programming » Packages » Question
  1. What is the output of this program?
    import java.lang.reflect.*;
    public class Additional_package_Example
    {
    public static void main(String args[])
    {
    try
    {
    Class object = Class.forName("java.awt.Dimension");
    Field fields[] = object.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 constructors of ‘java.awt.Dimension’ package
    3. program prints all the methods and data member of ‘java.awt.Dimension’ package
    4. Program prints all the data members of ‘java.awt.Dimension’ package
    5. None of these
Correct Option: D

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



Your comments will be displayed only after manual approval.