Java MCQs with answers Page - 31

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 • 832.27K Points
Coach

Q. Which of the following creates a List with 5 visible items and multiple selections enabled?

  • (A) new List(5, true)
  • (B) new List(true, 5)
  • (C) new List(5, false)
  • (D) new List(false, 5)

A

Admin • 832.27K Points
Coach

Q. An Applet has its Layout Manager set to the default of FlowLayout. What code would be the correct to change to another Layout Manager?

  • (A) setLayoutManager(new GridLayout());
  • (B) setLayout(new GridLayout(2,2));
  • (C) setGridLayout(2,2);
  • (D) setBorderLayout();

A

Admin • 832.27K Points
Coach

Q. How do you change the current layout manager for a container?

  • (A) Use the setLayout method.
  • (B) Once created you cannot change the current layout manager of a component
  • (C) Use the setLayoutManager meth
  • (D) None of the above

A

Admin • 832.27K Points
Coach

Q. Which of the following methods can be used to draw the outline of a square within a JAVA.awt.Component object?

  • (A) drawLine()
  • (B) fillRect()
  • (C) drawPolygon()
  • (D) None of the above

A

Admin • 832.27K Points
Coach

Q. State true or false
(i) JPanel is a class included in awt package
(ii) Anonymous classes are mostly used for event handling
(iii) Names of anonymous classes must be unique
(iv) JOptionPane is an inner class

  • (A) i-false, ii-false, iii-true, iv-true
  • (B) i-true, ii-false, iii-true, iv-false
  • (C) i-false, ii-true, iii-false, iv-false
  • (D) i-true, ii-true, iii-false, iv-true

A

Admin • 832.27K Points
Coach

Q. State true or false
(i) Java RMI supports distributed objects written entirely in java
(ii) Java RMI makes use of stubs and skeleton
(iii) In Java RMI an object registers itself with a media server
(iv) IDL is interface declaration language

  • (A) True, True, False, False
  • (B) False, True, True, True
  • (C) True, False, True, False
  • (D) True, True, True, True

A

Admin • 832.27K Points
Coach

Q. State true or false
(i) public can only be assigned to class (ii) protected protects a statement
(iii) protected method is never accessible outside the package
(iv) friendly variable may be accessible outside class

  • (A) True, True, False, True
  • (B) False, False, False, True
  • (C) False, True, False, False
  • (D) True, False, False, False

A

Admin • 832.27K Points
Coach

Q. The ________ method help in clearing the contents of the buffer:

  • (A) flush()
  • (B) clear()
  • (C) rub()
  • (D) vanish()

A

Admin • 832.27K Points
Coach

Q. Which of these methods are used to register a MouseMotionListener?

  • (A) addMouse()
  • (B) addMouseListener()
  • (C) addMouseMotionListner()
  • (D) eventMouseMotionListener()

A

Admin • 832.27K Points
Coach

Q. What is a listener in context to event handling?

  • (A) A listener is a variable that is notified when an event occurs.
  • (B) A listener is an interface that is notified when an event occurs.
  • (C) A listener is a method that is notified when an event occurs.
  • (D) None of the mentioned

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