✅ 25 Low-Level MCQ Questions
Java Programming Construct
1. Which of the following is a valid Java comment?
a) // This is a comment
b) /* This is a comment */
c) /** This is a doc comment */
d) All of the above
2. Which data type is used to store a true or false value?
a) int
b) boolean
c) char
d) String
3. What will be the output of System.out.println(5 + 3 * 2);?
a) 16
b) 11
c) 13
d) 10
4. Which keyword is used to define a variable in Java?
a) dim
b) let
c) var
d) No keyword is required; just the data type
5. Which operator is used for remainder in Java?
a) /
b) *
c) %
d) ^
6. Which of the following is not a primitive data type?
a) int
b) boolean
c) String
d) char
7. What is the result of typecasting int i = (int) 5.6;?
a) 5.6
b) 5
c) Compilation error
d) Runtime error
8. Which class is used for taking user input from the console?
a) SystemInput
b) Scanner
c) BufferReader
d) Console
Java Control Flow
9. What is the output of true && false?
a) true
b) false
c) error
d) null
10.Which control structure is used for multiple condition selection?
a) if
b) if-else
c) switch
d) while
11.Which loop executes at least once even if the condition is false?
a) for
b) while
c) do-while
d) None
12.Which keyword is used to exit a loop prematurely?
a) exit
b) stop
c) break
d) continue
13.What does the continue keyword do in a loop?
a) Exits the loop
b) Skips the current iteration
c) Repeats the last iteration
d) Skips the loop entirely
14.Which of these is a valid syntax of switch statement?
a) switch(i)
b) switch i:
c) if (switch i)
d) loop switch(i)
15.In if-else if ladder, how many conditions are checked?
a) Only the first one
b) All, until one is true
c) Only the last
d) Only the else block
Java Arrays
16.How do you declare an array in Java?
a) int array[];
b) array int[];
c) int[] array;
d) Both a and c
17.What is the index of the first element in an array?
a) 0
b) 1
c) -1
d) Depends on size
18.How can you find the number of elements in an array arr?
a) arr.length()
b) arr.size()
c) arr.length
d) arr.count()
19.Which loop is commonly used to access array elements?
a) do-while
b) if
c) for
d) switch
20.How do you change the value of an element in an array at index 2?
a) arr(2) = 10;
b) arr[2] = 10;
c) arr.set(2, 10);
d) arr -> 2 = 10;
21.Which is the correct way to declare a 2D array in Java?
a) int[][] matrix = new int[3][3];
b) int matrix[][] = new int[3][3];
c) int matrix[3][3];
d) Both a and b
22.Which of the following best describes a 2D array?
a) A list of lists
b) A matrix
c) An array with rows and columns
d) All of the above
Java Methods
23.Which keyword is used to define a method?
a) method
b) function
c) void
d) return
24.Which of the following is true about static methods?
a) They require an object to be called
b) They belong to the class, not the instance
c) They can't return values
d) They must be private
25.What is the purpose of standard library methods like Math.max()?
a) To define new methods
b) To reuse built-in functionalities
c) To perform string operations only
d) None of the above
✅ 3 Coding Questions
1. Sum of Two Numbers (Using Scanner and Arithmetic Operators)
Problem:
Write a Java program to take two integers as input from the user and print their sum, difference,
and product.
2. Find Maximum Number in an Array
Problem:
Write a Java program that takes an array of integers and prints the largest number using a loop.
3. Define and Use a Method to Check Even/Odd
Problem:
Create a method isEven(int num) that returns true if the number is even, otherwise
false.
Take a number from the user and call the method to check.
4. Java Programming Constructs & Control Flow
1. Take two numbers from the user and print their sum.
2. Write a program to check if a number is even or odd.
3. Write a program to find the larger of two numbers using if-else.
4. Take a number as input and print the multiplication table of that number using a
loop.
5. Write a program that prints numbers from 1 to 10 using a while loop.
6. Write a program to find the sum of all numbers from 1 to n.
7. Take three marks as input and calculate the average of the marks.
8. Write a program to check whether a number is positive, negative, or zero.
9. Take a number from the user and check if it is divisible by 5 and 11.