559). Which of these classes encapsulate runtime environment?
[A]Class
[B]System
[C]Runtime
[D]ClassLoader
Show Answer
Correct Answer: Runtime
Notes:
Answer: c
Explanation: None.
560). Which of the following exceptions is thrown by every method of Runtime class?
[A]IOException
[B]SystemException
[C]SecurityException
[D]RuntimeException
Show Answer
Correct Answer: SecurityException
Notes:
Answer: c
Explanation: Every method of Runtime class throws SecurityException.
561). Which of the following exceptions is thrown by every method of Runtime class?
[A]IOException
[B]SystemException
[C]SecurityException
[D]RuntimeException
Show Answer
Correct Answer: SecurityException
Notes:
Answer: c
Explanation: Every method of Runtime class throws SecurityException.
562). Which of these methods returns the total number of bytes of memory available to the program?
[A] getMemory()
[B]TotalMemory()
[C]SystemMemory()
[D] getProcessMemory()
Show Answer
Correct Answer: TotalMemory()
Notes:
Answer: b
Explanation: TotalMemory() returns the total number of bytes available to the program.
563). Which of these Exceptions is thrown by loadClass() method of ClassLoader class?
[A]IOException
[B]SystemException
[C]ClassFormatError
[D]ClassNotFoundException
Show Answer
Correct Answer: ClassNotFoundException
Notes:
Answer: d
Explanation: None.
564). What will be the output of the following Java program?
class X
{
int a;
double b;
}
class Y extends X
{
int c;
}
class Output
{
public static void main(String args[])
{
X a = new X();
Y b = new Y();
Class obj;
obj = b.getClass();
System.out.print(obj.getSuperclass());
}
}
[A]X
[B]Y
[C]class X
[D]class Y
Show Answer
Correct Answer: class X
Notes:
Answer: c
Explanation: getSuperClass() returns the super class of an object. b is an object of class Y which extends class X , Hence Super class of b is X. therefore class X is printed.
Output:$ javac Output.java
$ java Output
class X
565). What will be the output of the following Java program?
class X
{
int a;
double b;
}
class Y extends X
{
int c;
}
class Output
{
public static void main(String args[])
{
X a = new X();
Y b = new Y();
Class obj;
obj = b.getClass();
System.out.print(b.equals(a));
}
}
[A]0
[B]1
[C]true
[D]false
Show Answer
Correct Answer: false
Notes:
Answer: d
Explanation: None.
Output:
$ javac Output.java
$ java Output
false
566). What will be the output of the following Java program?
class X
{
int a;
double b;
}
class Y extends X
{
int c;
}
class Output
{
public static void main(String args[])
{
X a = new X();
Y b = new Y();
Class obj;
obj = b.getClass();
System.out.print(obj.isInstance(a));
}
}
[A]0
[B]1
[C]true
[D]false
Show Answer
Correct Answer: false
Notes:
Answer: d
Explanation: Although class Y extends class X but still a is not considered related to Y. hence isInstance() returns false.
Output:
$ javac Output.java
$ java Output
false