Java MCQs with answers Page - 7

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

Q. Which of these operators is used to allocate memory to array variable in Java?

  • (A) malloc
  • (B) alloc
  • (C) new
  • (D) new malloc

A

Admin • 831.35K Points
Coach

Q. Which of the following loops will execute the body of loop even when condition controlling the loop is initially false?

  • (A) do-while
  • (B) while
  • (C) for
  • (D) None of the mentioned

A

Admin • 831.35K Points
Coach

Q. Which of these is necessary condition for automatic type conversion in Java?

  • (A) The destination type is smaller than source type.
  • (B) The destination type is larger than source type.
  • (C) The destination type can be larger or smaller than source type.
  • (D) None of the mentioned

A

Admin • 831.35K Points
Coach

Q. What is the error in this code? byte b = 50; b = b * 50;

  • (A) b can not store the result 2500, limited by its range
  • (B) * operator has converted b * 50 into int, which can not be converted to byte without casting.
  • (C) b can not contain value 50.
  • (D) No error in this code

A

Admin • 831.35K Points
Coach

Q. Which of these is an incorrect array declaration?

  • (A) int arr[] = new int[5];
  • (B) int [] arr = new int[5];
  • (C) int arr[]; arr = new int[5];
  • (D) int arr[] = int [5] new

A

Admin • 831.35K Points
Coach

Q. Which of these selection statements test only for equality?

  • (A) if
  • (B) switch
  • (C) Both a & b
  • (D) None of the mentioned

A

Admin • 831.35K Points
Coach

Q. Which of these are selection statements in Java?

  • (A) if
  • (B) for
  • (C) continue
  • (D) all of these

A

Admin • 831.35K Points
Coach

Q. Which of these jump statements can skip processing remainder of code in its body for a particular iteration?

  • (A) break
  • (B) return
  • (C) exit
  • (D) continue

A

Admin • 831.35K Points
Coach

Q. What is the value of the expression 2 & 3 ?

  • (A) 2
  • (B) 3
  • (C) 5
  • (D) 6

A

Admin • 831.35K Points
Coach

Q. What is the value of the expression 8 << 2 ?

  • (A) 2
  • (B) 32
  • (C) 1 6
  • (D) 5

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