Top 250+ Solved Java Programming MCQ Questions Answer
Q. Which method in Thread class is used to check weather a thread is still running?
a. isAlive()
b. Join()
c. isRunning()
d. Alive()
Q. Which of these class contains the methods print() & println()?
a. System
b. System.out
c. BufferedOutputStream
d. PrintStream
Q. To design a general-purpose search method, searchList, to search a list, which of thefollowing must be parameters of the method searchList? (i) The array containing the list. (ii) The length of the list. (iii) The search item. (iv) A boolean variable indicating whether the search is successful.
a. (i) and (ii)
b. (i), (ii), and (iii)
c. (ii), (iii), and (iv)
d. (i), (ii), (iii), and (iv)
Q. Consider the following list.list = {24, 20, 10, 75, 70, 18, 60, 35} Suppose that list is sorted using the selection sort algorithm as discussed in the book. What is the resulting list after two passes of the sorting phase, that is, after two iteration of the outer for loop?
a. list = {10, 18, 24, 20, 75, 70, 60, 35}
b. list = {10, 18, 20, 24, 75, 70, 60, 35}
c. list = {10, 18, 24, 75, 70, 20, 60, 35}
d. None of these
Q. Which method would you most likely use to add an element to an end of a vector?
a. insertElementAt
b. addElement
c. copyInto
d. lastElement
Q. An abstract method ____.
a. is any method in the abstract class
b. cannot be inherited
c. has no body
d. is found in a subclass and overrides methods in a super-class using the reserved word abstract
Q. The classes Reader and Writer are derived from the class _________.
a. Streams
b. Inputs
c. Outputs
d. Object
Q. The method toString() is a public member of the class _____________.
a. Object
b. String
c. Writer
d. Output
Q. For the interface WindowListener that contains more than one method, Java provides theclass ____.
a. MouseAdapter
b. WindowAdapter
c. KeyListener
d. KeyAdapter
Q. If a negative value is used for an array index, ____.
a. a NumberFormatException is thrown
b. the program terminates immediately
c. the last index of the array is automatically accessed instead
d. an IndexOutOfBoundsException is thrown
Q. Which of these packages contains all the classes and methods required for even handlingin Java?
a. javapplet
b. java.awt
c. java.event
d. java.awt.event
Q. What is an event in delegation event model used by Java programming language?
a. An event is an object that describes a state change in a source.
b. An event is an object that describes a state change in processing.
c. An event is an object that describes any change by the user and system.
d. An event is a class used for defining object, to create events.
Q. Which of these methods are used to register a keyboard event listener?
a. KeyListener()
b. addKistener()
c. addKeyListener()
d. eventKeyboardListener()