Output Questions in Java - With Answers
Q1. Find the output of the code:
Sample constructor
50
Q2. Predict the output of the following code.
Compilation Error – static method cannot access non-static variable 'rollno'.
Q3.
11 12 13
Q4.
x=6
res=false
Q5.
x=5
res=false
Q6. Difference between Logical AND(&&) and Bitwise AND(&):
&& – Logical AND, short-circuits if first condition false.
& – Bitwise AND, always evaluates both sides.
Q7.
50
25
12
6
3
Q8.
10
20
40
80
160
Q9.
a: 12
b: 11
c: 11
Q10.
age=false
Q11.
30SILICON
SILICON1020
Q12.
Hello B25use of this keyword
Q13.
20
Q14.
Programming
Value of num: 67
Q15.
30
Q16.
A class Const
B class Const
C class Const
D class Const
Q17.
Compilation Error – cannot override final method.
Q18.
Compilation Error – private variable 'j' not accessible in subclass.