class A { int i; int j; A() { i = 1; j = 2; } } class Output { public static void main(String args[]) { A obj1 = new A(); System.out.print(obj1.toString()); } }
true
false
String associated with obj1
Compilation Error
Explanation:-
Answer: Option C. -> String associated with obj1
toString() is method of class Object, since it is superclass of every class, every object has this
method. toString() returns the string associated with the calling object. output: $ javac Output.java $ java Output A@1cd2e5f
Question 9.
What value will this program return to Java run-time system?
import java.lang.System; class Output { public static void main(String args[]) { System.exit(5); } }
0
1
4
5
Explanation:-
Answer: Option D. -> 5
None.
Question 10.
Will this program generate same output is executed again?
class Output { public static void main(String args[]) { int y = double z = Math.random(); System.out.print(y); } }
Yes
No
Compiler Dependent
Operating System Dependent
Explanation:-
Answer: Option B. -> No
There is no relation between random numbers generated previously in Java.