Packages
- 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");
}
}
}
-
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()
- 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;
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
IntervieW
- 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);
}
}
-
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.
- Which of these package is used for graphical user interface?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
java.awt provides capabilities for graphical user interface.
- Which of this package is used for analyzing code during run-time?
-
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.