427). Which of these class have only one field ‘TYPE’?
[A]Void
[B]Process
[C]System
[D]Runtime
Show Answer
Correct Answer: Void
Notes:
Answer: a
Explanation: The Void class has one field, TYPE, which holds a reference to the Class object for the type void.
428). Which of the following method of Process class can terminate a process?
[A] void kill()
[B]void destroy()
[C] void terminate()
[D]void exit()
Show Answer
Correct Answer: void destroy()
Notes:
Answer: b
Explanation: Kills the subprocess. The subprocess represented by this Process object is forcibly terminated.
429). Standard output variable ‘out’ is defined in which class?
[A]Void
[B]Process
[C]Runtime
[D]System
Show Answer
Correct Answer: System
Notes:
Answer: d
Explanation: Standard output variable ‘out’ is defined in System class. out is usually used in print statement i:e System.out.print().
430). Which of these class can encapsulate an entire executing program?
[A]Void
[B]Process
[C]Runtime
[D]System
Show Answer
Correct Answer: Process
Notes:
Answer: b
Explanation: None.
431). Which of the following is method of System class is used to find how long a program takes to execute?
[A]currenttime()
[B]currentTime()
[C]currentTimeMillis()
[D]currenttimeMillis()
Show Answer
Correct Answer: currentTimeMillis()
Notes:
Answer: c
Explanation: None.
432). Which of these class holds a collection of static methods and variables?
[A]Void
[B]Process
[C]Runtime
[D]System
Show Answer
Correct Answer: System
Notes:
Answer: d
Explanation: System class holds a collection of static methods and variables. The standard input, output and error output of java runtime is stored in the in, out and err variables of System class.
433). What will be the output of the following Java code?
class Output
{
public static void main(String args[])
{
long start, end;
start = System.currentTimeMillis();
for (int i = 0; i < 10000000; i++);
end = System.currentTimeMillis();
System.out.print(end - start);
}
}
[A]0
[B]1
[C]100
[D] System Dependent
Show Answer
Correct Answer: System Dependent
Notes:
Answer: d
Explanation: end time is the time taken by loop to execute it can be any non zero value depending on the System.
Output:$ javac Output.java
$ java Output
78
434). What will be the output of the following Java code?
class Output
{
public static void main(String args[])
{
byte a[] = { 65, 66, 67, 68, 69, 70 };
byte b[] = { 71, 72, 73, 74, 75, 76 };
System.arraycopy(a , 0, b, 0, a.length);
System.out.print(new String(a) + " " + new String(b));
}
}
[A]ABCDEF ABCDEF
[B]ABCDEF GHIJKL
[C]GHIJKL ABCDEF
[D]GHIJKL GHIJKL
Show Answer
Correct Answer: ABCDEF ABCDEF
Notes:
Answer: a
Explanation: System.arraycopy() is a method of class System which is used to copy a string into another string.
Output:
$ javac Output.java
$ java Output
ABCDEF ABCDEF
435). What will be the output of the following Java code?
class Output
{
public static void main(String args[])
{
byte a[] = { 65, 66, 67, 68, 69, 70 };
byte b[] = { 71, 72, 73, 74, 75, 76 };
System.arraycopy(a, 2, b, 1, a.length-2);
System.out.print(new String(a) + " " + new String(b));
}
}
[A] ABCDEF GHIJKL
[B]ABCDEF GCDEFL
[C]GHIJKL ABCDEF
[D]GCDEFL GHIJKL
Show Answer
Correct Answer: ABCDEF GCDEFL
Notes:
Answer: b
Explanation: None.
Output:
$ javac Output.java
$ java Output
ABCDEF GCDEFL
436). What will be the output of the following Java code?
class Output
{
public static void main(String args[])
{
byte a[] = { 65, 66, 67, 68, 69, 70 };
byte b[] = { 71, 72, 73, 74, 75, 76 };
System.arraycopy(a, 1, b, 3, 0);
System.out.print(new String(a) + " " + new String(b));
}
}
[A]ABCDEF GHIJKL
[B]ABCDEF GCDEFL
[C]GHIJKL ABCDEF
[D] GCDEFL GHIJKL
Show Answer
Correct Answer: ABCDEF GHIJKL
Notes:
Answer: a
Explanation: Since last parameter of System.arraycopy(a,1,b,3,0) is 0 nothing is copied from array a to array b, hence b remains as it is.
Output:
$ javac Output.java
$ java Output
ABCDEF GHIJKL