AllInfoHub Logo

AllInfoHub – MCQ Practice

Introduction to Java – Multiple Choice Questions (MCQs)

  1. 37. What is the output of `System.out.println(8 >> 2);`?

    • A. 1
    • B. 2
    • C. 4
    • D. 6
  2. 38. What is the output of `System.out.println(-8 >> 2);`?

    • A. -1
    • B. -2
    • C. -4
    • D. -6
  3. 39. What is the output of `System.out.println(-8 >>> 2);`?

    • A. 2147483646
    • B. 2147483647
    • C. -2
    • D. 2
  4. 40. Which of the following is a looping construct in Java?

    • A. if-else
    • B. switch-case
    • C. try-catch
    • D. for
  5. 41. Which of the following is a selection construct in Java?

    • A. for loop
    • B. while loop
    • C. do-while loop
    • D. if-else
  6. 42. What is the output of `System.out.println(true && false);`?

    • A. TRUE
    • B. FALSE
    • C. error
    • D. 1
  7. 43. What is the output of `System.out.println(true || false);`?

    • A. TRUE
    • B. FALSE
    • C. error
    • D. 0
  8. 44. What is the output of `System.out.println(!true);`?

    • A. TRUE
    • B. FALSE
    • C. error
    • D. 1
  9. 45. What is the purpose of the `break` statement in Java?

    • A. To exit a loop or switch statement
    • B. To skip the current iteration of a loop
    • C. To define a block of code
    • D. To declare a variable
  10. 46. What is the purpose of the `continue` statement in Java?

    • A. To exit a loop or switch statement
    • B. To skip the current iteration of a loop
    • C. To define a block of code
    • D. To declare a variable
  11. 47. What is the output of the following code? `int x = 5; if (x > 3) System.out.println(\Yes\"); else System.out.println(\""No\"");`?"""

    • A. Yes
    • B. No
    • C. Error
    • D. None
  12. 48. What is the output of the following code? `int y = 2; if (y > 3) System.out.println(\A\"); else if (y == 2) System.out.println(\""B\""); else System.out.println(\""C\"");`?"""

    • A. A
    • B. B
    • C. C
    • D. Error