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 the correct syntax to declare a variable in Java?
Which keyword is used to create a constant variable in Java?
What will be the output of the following code? int x = 5; x += 3; System.out.println(x);
Which of the following is NOT a primitive data type in Java?
What is the size of 'char' data type in Java?
Which of the following will compile without error? public static void main(String args[]) { int x = 10; final int y = 20; y = 30; }
What is the output of: System.out.println();
Which operator has the highest precedence in Java?
What is the output of: System.out.println(5 > 3 ? 'A' : 'B');
Which statement is correct about Java variables?
Consider the code: int a = 5; int b = a++; System.out.println(a + " " + b); What is the output?
What will be printed? System.out.println(10 + 20 + "Java");
Identify the output: System.out.println("Java".length());
What is the scope of a local variable in Java?
Which of the following is the correct way to declare and initialize an array in Java?
What will be the output of: boolean flag = true; System.out.println(!flag);
Consider: int x = 0; System.out.println(x == 0 && x != 1); What is the output?
What will be the output of: System.out.println();
Which keyword is used to prevent a class from being inherited?
Which of the following is a valid variable name in Java?