Packages


  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 obj = Class.forName("java.awt.Dimension");
    Method methods[] = obj.getMethods();
    for (int k = 0; k < methods.length; k++)
    System.out.println(methods[k]);
    }
    catch (Exception e)
    {
    System.out.print("Exception");
    }
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

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

    public double java.awt.Dimension.getWidth()
    public double java.awt.Dimension.getHeight()
    public boolean java.awt.Dimension.equals(java.lang.Object)
    public java.lang.String java.awt.Dimension.toString()
    public int java.awt.Dimension.hashCode()
    public java.awt.Dimension java.awt.Dimension.getSize()
    public void java.awt.Dimension.setSize(double,double)
    public void java.awt.Dimension.setSize(int,int)
    public void java.awt.Dimension.setSize(java.awt.Dimension)
    public java.lang.Object java.awt.geom.Dimension2D.clone()
    public void java.awt.geom.Dimension2D.setSize(java.awt.geom.Dimension2D)
    public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException
    public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException
    public final void java.lang.Object.wait() throws java.lang.InterruptedException
    public final native java.lang.Class java.lang.Object.getClass()
    public final native void java.lang.Object.notify()
    public final native void java.lang.Object.notifyAll()


  1. What is the output of this program?
    package pack;
    public class Result
    {
    public static void main(String args[])
    {
    StringBuffer strbuf = new StringBuffer("IntervieM");
    strbuf.setCharAt(8, 'W');
    System.out.println(strbuf);
    }
    }

    Note : Result.class file is in directory pack;











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    IntervieW



  1. What is the output of this program?
     package pack;
    public class Result
    {
    public static void main(String args[])
    {
    StringBuffer strbuf = new StringBuffer("Hello Mania");
    strbuf.insert(6 , "Interview ");
    System.out.println(strbuf);
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Since Result.class file is not in the directory pkg in which class Result is defined, program will not be able to run.


  1. Which of these package is used for graphical user interface?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    java.awt provides capabilities for graphical user interface.



  1. Which of this package is used for analyzing code during run-time?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Reflection is the ability of a software to analyze itself. This is provided by java.lang.reflect package.