Interfaces And Abstract Classes - Study Mode
[#236] 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))
}
}
Correct Answer
(B) ABCDEF GCDEFL
[#237] What will be the output of the following Java program? (Note: file is made in c drive.) import java.io.*
class files
{
public static void main(String args[])
{
File obj = new File("/java/system")
System.out.print(obj.getAbsolutePath())
}
}
Correct Answer
(D) javasystem
[#238] What will be the output of the following Java program? class Output
{
public static void main(String args[])
{
String str = "true"
boolean x = Boolean.valueOf(str)
System.out.print(x)
}
}
Correct Answer
(A) True
(E) True
[#239] What will be the output of the following Java program? (Note: file is made in c drive.) import java.io.*
class files
{
public static void main(String args[])
{
File obj = new File("/java/system")
System.out.print(obj.canWrite())
System.out.print(" " + obj.canRead())
}
}
Correct Answer
(D) false false
[#240] What will be the output of the following Java program? public class BoxDemo
{
public static <U> void addBox(U u,
java.util.List<Box<U>> boxes)
{
Box<U> box = new Box<>()
box.set(u)
boxes.add(box)
}
public static <U> void outputBoxes(java.util.List<Box<U>> boxes)
{
int counter = 0
for (Box<U> box: boxes)
{
U boxContents = box.get()
System.out.println("[" + boxContents.toString() + "]")
counter++
}
}
public static void main(String[] args)
{
java.util.ArrayList<Box<Integer>> listOfIntegerBoxes = new java.util.ArrayList<>()
BoxDemo.<Integer>addBox(Integer.valueOf(0), listOfIntegerBoxes)
BoxDemo.outputBoxes(listOfIntegerBoxes)
}
}
Correct Answer
(D) [0]