Top 250+ Solved Java Programming MCQ Questions Answer

From 121 to 135 of 285

Q. Which of the below is invalid identifier with the main method?

a. public

b. static

c. private

d. final

  • c. private

Q. Which of these can not be used for a variable name in Java?

a. identifier

b. keyword

c. identifier & keyword

d. none of the mentioned

  • b. keyword

Q. which of the following can be operands of arithmetic operators?

a. Numeric

b. Boolean

c. Characters

d. Both Numeric & Characters

  • d. Both Numeric & Characters

Q. How to copy contents of array?

a. System.arrayCopy()

b. Array.copy()

c. Arrays.copy()

d. Collection.copy()

  • a. System.arrayCopy()

Q. Which of these are selection statements in Java?

a. if()

b. for()

c. continue

d. break

  • a. if()

Q. Which of these operators is used to allocate memory for an object?

a. malloc

b. alloc

c. new

d. give

  • c. new

Q. Which of these packages contains the exception Stack Overflow in Java?

a. javlang

b. java.util

c. java.io

d. java.system

  • a. java.lang

Q. Which of this method of class String is used to obtain a length of String object?

a. get()

b. Sizeof()

c. lengthof()

d. length()

  • d. length()

Q. Which of these methods of a Thread class is used to suspend a thread for a period of time?

a. sleep()

b. terminate()

c. suspend()

d. stop()

  • a. sleep()

Q. Which of these exceptions will be thrown if we use null reference for an arithmeticoperation?

a. ArithmeticException

b. NullPointerException

c. IllegalAccessException

d. IllegalOperationException

  • b. NullPointerException

Q. Which of the interface contains all the methods used for handling thread related operationsin Java?

a. Runnable interface

b. Math interface

c. System interface

d. ThreadHandling interface

  • a. Runnable interface

Q. Which of these class is used to read and write bytes in a file?

a. FileReader

b. FileWriter

c. FileInputStream

d. InputStreamReader

  • c. FileInputStream

Q. Which of these classes is used for input and output operation when working with bytes?

a. InputStream

b. Reader

c. Writer

d. All of the mentioned

  • a. InputStream

Q. Which of these class is a superclass of all other classes?

a. Math

b. Process

c. System

d. Object

  • d. Object

Q. Which of these class is not a member class of java.io package?

a. String

b. StringReader

c. Writer

d. File

  • a. String
Subscribe Now

Get All Updates & News