NEW
Font size
WorksheetsObject Oriented Programming
Total questions: 65
Worksheet time: 27mins
After saving a Java source file named Calculator.java containing public class Calculator, what happens if you run javac Calc.java?
It compiles successfully and creates Calculator.class
It throws an error because Calc.java does not exist
It runs but produces incorrect bytecode
It renames the file automatically
Which command correctly executes a compiled Java class named MainApp?
java MainApp.class
javac MainApp
java MainApp
javac MainApp.java MainApp
Which condition correctly checks if a year is a leap year?
(year % 4 == 0)
(year % 100 == 0 || year % 400 == 0)
(year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)
(year % 400 == 0)
Fibonacci series of 6 terms starting from 0, 1 is:
0, 1, 1, 2, 3, 5
1, 1, 2, 3, 5, 8
0, 1, 2, 3, 5, 8
0, 1, 1, 2, 4, 6
Which operator is used to check divisibility in Java?
%
//
&&
==
The formula for calculating simple interest in Java is:
P * R * T / 100
P + R + T
P * R / T
P / R * T
Which loop correctly prints numbers 1 to 100?
for(i=1;i<=100;i++)
for(i=0;i<100;i--)
while(i<=100;i++)
do while(i<100)
The factorial of 5 is:
10
60
120
720
Palindrome check for string "madam" returns:
Not Palindrome
Palindrome
Error
madam
Which one is NOT a correct vowel check in Java?
if(c=='a')
if(c=='e')
if(c.equals('i'))
if(c=='o')
What is the Fahrenheit equivalent of 0°C?
0
32
100
212
The average of 4, 6, and 8 is:
5
6
7
8
The quotient of 15 / 4 is:
3
3.75
4
0
15 % 4 resolve to ...
1
2
3
4
The GCD of 20 and 28 is:
2
4
6
8
The LCM of 4 and 6 is:
12
18
20
24
Which of the following is an Armstrong number?
123
153
370
Both b and c
Reversing the string "Java" gives:
avaJ
Java
Jvaa
aavJ
How many tokens are in "I love Java"?
2
3
4
5
Prime numbers between 1 and 10 are:
2,3,5,7
1,2,3,5,7
2,4,6,8
3,6,9
The sum of the first 5 natural numbers is:
10
15
20
25
The absolute value of -12 is:
-12
12
0
Error
What happens if an array index goes out of range?
Nothing
Compilation error
Runtime error
Loops back
The value of 2^5 computed without Math.pow is:
10
20
25
32
The program checking if 29 is prime returns:
True
False
Error
0
The factorial program output for 0! is:
0
1
Undefined
Error
The program counting vowels in "education" gives:
3
4
5
6
The program merging arrays {1,2} and {3,4} results in:
{1,2,3,4}
{3,4,1,2}
{1,3,2,4}
{2,1,4,3}
A number divisible by both 3 and 5 will satisfy:
num % 3 == 0 && num % 5 == 0
num % 3 == 0 || num % 5 == 0
num / 3 == 5
num * 3 == 5
When simulating a calculator, if input is 12 * 4, the output is:
16
36
48
124
