Explore topic-wise MCQs in Java Programming.

This section includes 7 Mcqs, each offering curated multiple-choice questions to sharpen your Java Programming knowledge and support exam preparation. Choose a topic below to get started.

1.

What is the length of the application box made by this program?
import java.awt.*;
import java.applet.*;
public class Newapplet extends Applet
{
Graphic G;
G.drawString("A Simple Applet created...",100,100);
}

A. A Simple Applet created...
B. 10
C. 100
D. Compilation Error
E. Runtime Error
Answer» E. Runtime Error
2.

What is the length of the application box made by this program?
import java.awt.*;
import java.applet.*;
public class TextApplet extends Applet
{
Graphic gra;
g.drawString("A Simple Applet", 30, 30);
}

A. 30
B. Runtime Error
C. Compilation Error
D. Default value
E. None of these
Answer» D. Default value
3.

What is the length of the application box made by this program?
import java.awt.*;
import java.applet.*;
public class TextApplet extends Applet
{
public void paint(Graphics g)
{
g.drawString("A Simple Applet created...", 50, 50);
}
}

A. 20
B. 30
C. 40
D. 50
E. 60
Answer» E. 60
4.

What is the Message is displayed in the applet made by this program?
import java.awt.*;
import java.applet.*;
public class TextApplet extends Applet
{
public void paint(Graphics g)
{
g.drawString("A Simple Applet created...", 40, 40);
}
}

A. A simple applet created...
B. A simple applet created... 40 40
C. Runtime Error
D. Compilation Error
E. None of these
Answer» B. A simple applet created... 40 40
5.

What is the length of the application box made by this program?
import java.awt.*;
import java.applet.*;
public class Applet_Example extends Applet
{
Graphic graphic;
graphic.drawString("A Simple Applet",25, 25);
}

A. Compilation Error
B. Runtime Error
C. Default Value
D. 25
E. None of these
Answer» B. Runtime Error
6.

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

A. Program prints all the methods and data member of java.awt.Dimension package
B. Program prints all the data members of java.awt.Dimension package
C. Program prints all the methods of java.awt.Dimension package
D. Program prints all the constructors of java.awt.Dimension package
E. None of these
Answer» D. Program prints all the constructors of java.awt.Dimension package
7.

What is the Message is displayed in the applet made by this program?

A. A simple applet created...
B. A simple applet created... 40 40
C. Runtime Error
D. Compilation Error
E. None of these
Answer» B. A simple applet created... 40 40