Java Programming - MCQ Practice Questions
Practice free Java Programming multiple-choice questions with detailed answers and explanations. Perfect for competitive exam preparation.
958 questions | 100% Free
Which of the following is a feature of Java 8 that allows functional programming?
What will be the output? class Test { public static void main(String[] args) { int x = 10; { int x = 20; System.out.println(x); } System.out.println(x); } }
Which of the following will throw a NullPointerException? String s = null; System.out.println(s.length());
Consider: class Parent { Parent() { System.out.println("P"); } } class Child extends Parent { Child() { System.out.println("C"); } } public static void main(String[] args) { new Child(); }
What is the output of: int x = 5; System.out.println(x++ + ++x);
Which keyword is used to create a constant variable in Java that cannot be modified after initialization?
What will be the result of: int a = 10; int b = 20; System.out.println(a + b + "Java");?
What is the purpose of the 'this' keyword in Java?
Consider the following code: int x = 5; x += 3; System.out.println(x); What is the output?
Which of the following correctly demonstrates method overloading?
What is the size of 'long' data type in Java?
Which of the following statements about static methods is correct?
What will happen if you try to access an index out of bounds in an array?
Which access modifier allows a member to be accessible only within the same package?
What is the output of: System.out.println();?
Which of the following is true about the 'break' statement?
What is the difference between 'break' and 'continue' in loop statements?
Which statement about constructors is INCORRECT?
What will be the output of: int x = 5; System.out.println(++x + x++);?
Which of the following correctly represents variable declaration and initialization in Java?