Java MCQs with answers Page - 20

Here, you will find a collection of MCQ questions on Java. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 833.24K Points
Coach

Q. A ------------- is a component that can hold other components.

  • (A) A window
  • (B) a container
  • (C) A control
  • (D) a form

A

Admin • 833.24K Points
Coach

Q. The method that returns the selected item from a List component is

  • (A) getSelected()
  • (B) getSelectedString()
  • (C) getSelectedItem()
  • (D) getSelectedData()

A

Admin • 833.24K Points
Coach

Q. The class used to make a standalone application in java.

  • (A) Applet
  • (B) Panel
  • (C) Frame
  • (D) Form

A

Admin • 833.24K Points
Coach

Q. ------------------- is an example of container class

  • (A) Label
  • (B) Panel
  • (C) TextField
  • (D) Button

A

Admin • 833.24K Points
Coach

Q. The class used to encapsulate fonts is

  • (A) Graphics
  • (B) Font
  • (C) Applet
  • (D) Component

A

Admin • 833.24K Points
Coach

Q. Number of primitive data types in Java are?

  • (A) 6
  • (B) 7
  • (C) 8
  • (D) 9

A

Admin • 833.24K Points
Coach

Q. What is the size of float and double in java?

  • (A) 32 and 64
  • (B) 32 and 32
  • (C) 64 and 64
  • (D) 64 and 32

A

Admin • 833.24K Points
Coach

Q. Automatic type conversion is possible in which of the possible cases?

  • (A) Byte to int
  • (B) Int to long
  • (C) Long to int
  • (D) Short to int

A

Admin • 833.24K Points
Coach

Q. Find the output of the following code

Code:
int Integer = 24;
char String  = ‘I’;
System.out.print(Integer);
System.out.print(String);
  • (A) Compile error
  • (B) Throws exception
  • (C) I
  • (D) 24 I

A

Admin • 833.24K Points
Coach

Q. Find the output of the following program.

Code:
public class Solution{
       public static void main(String[] args){
                     short x = 10;
                     x =  x * 5;
                     System.out.print(x);
       }
}
  • (A) 50
  • (B) 10
  • (C) Compile error
  • (D) Exception

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ