71. Which of these methods is used to check for infinitely large and small values?
72. What is true about the setProperties method?
73. What will be the output of the following Java program?
import java.io.*;
class Chararrayinput
{
public static void main(String[] args)
{
String obj = "abcdef";
int length = obj.length();
char c[] = new char[length];
obj.getChars(0,length,c,0);
CharArrayReader input1 = new CharArrayReader(c);
CharArrayReader input2 = new CharArrayReader(c, 0, 3);
int i;
try
{
while ((i = input1.read()) != -1)
{
System.out.print((char)i);
}
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
import java.io.*;
class Chararrayinput
{
public static void main(String[] args)
{
String obj = "abcdef";
int length = obj.length();
char c[] = new char[length];
obj.getChars(0,length,c,0);
CharArrayReader input1 = new CharArrayReader(c);
CharArrayReader input2 = new CharArrayReader(c, 0, 3);
int i;
try
{
while ((i = input1.read()) != -1)
{
System.out.print((char)i);
}
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
74. Java system properties can be set at runtime.
75. 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));
}
}
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));
}
}
76. 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());
}
}
import java.io.*;
class files
{
public static void main(String args[])
{
File obj = new File("/java/system");
System.out.print(obj.getAbsolutePath());
}
}
77. 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);
}
}
class Output
{
public static void main(String args[])
{
String str = "true";
boolean x = Boolean.valueOf(str);
System.out.print(x);
}
}
78. 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());
}
}
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());
}
}
79. 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);
}
}
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);
}
}
80. What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
Integer i = new Integer(257);
float x = i.floatValue();
System.out.print(x);
}
}
class Output
{
public static void main(String args[])
{
Integer i = new Integer(257);
float x = i.floatValue();
System.out.print(x);
}
}
Read More Section(Interfaces and Abstract Classes)
Each Section contains maximum 100 MCQs question on Interfaces and Abstract Classes. To get more questions visit other sections.