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");
    Constructor constructors[] = obj.getConstructors();
    for (int k = 0; k < constructors.length; k++)
    System.out.println(constructors[k]);
    }
    catch (Exception e)
    {
    System.out.print("Exception");
    }
    }
    }

    1. Program prints all the possible constructors of class ‘Class’
    2. Program prints all the constructors of ‘java.awt.Dimension’ package
    3. Runtime Error
    4. Program prints “Exception”
    5. None of these
Correct Option: B

Output:
public java.awt.Dimension()
public java.awt.Dimension(int,int)
public java.awt.Dimension(java.awt.Dimension)



Your comments will be displayed only after manual approval.