Font size
WorksheetsJava Sothanaigal 2.0
Total questions: 16
Worksheet time: 13mins
Java saw this code and laughed. Why? 😄
int age = 18;
if(age = 18)
System.out.println("Eligible");
Not Eligible will print
Assignment used instead of comparison
age is too young
Eligible
Java drank coffee ☕ and executed:
int x = 5;
System.out.println(x++ + x++ + ++x);
18
19
20
21
Java asks: “Who comes first?” 🤨
int x = 10;
System.out.println(++x * x++);
110
121
120
Error
This loop escaped from jail 🏃♂️
for(int i=1; i<=5; i--)
System.out.print(i);
12345
54321
Infinite loop
Compile Error
Java got emotionally confused 😵
String s1 = "Java";
String s2 = "Java";
System.out.println(s1 == s2);
true
false
error
Depends
Java asks: “Who am I?” 🤔
class Test {
int x;
}
-->x is:
Object
Method
Instance variable
Class
int x = 0;
if(x++ == 0 && ++x == 2)
System.out.println("True");
else
System.out.println("False");
Output?
True
False
Error
Nothing
for(int i=1;i<=3;i++)
{
for(int j=1;j<=i;j++)
System.out.print(j);
}
123
112123
121
123123
int i = 1;
System.out.print(i++ + ++i);
3
4
5
6
Which one makes Java say “I don’t know what to do” 😵?
Infinite loop
Ambiguous method call
Array out of bound
All of the above
Java said: “I am very secure 🔐”. Why?
It uses antivirus
It has strong password
It uses Encapsulation
It hides from hackers
Why did the Java loop break up with the condition? 💔
Condition was false
Infinite relationship
No increment
All of the above
Java’s garbage collector does which job? 🧹
Deletes unused memory
Cleans your PC
Deletes bugs
Makes program faster always
What happens if a program has no logic, but no syntax error?
Program fails
Compile error
Wrong output
Program doesn’t run
int a = 5; // 0101
int b = 3; // 0011
System.out.println(a & b);
1
3
7
5
Draw an array as a train 🚂

