Question 1 of 25
Hints left: 3
Q1
How to assign values to variable using property?
Q2
What will be the output of the following Java program? import java.lang.System; 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, 3, a.length - 4); System.out.print(new String(a) + " " + new String(b)); } }
Q3
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.getParent()); System.out.print(" " + obj.isFile()); } }
Q4
Which of the following exceptions is thrown by every method of Runtime class?
Q5
Which of the following access specifiers can be used for an interface?
Q6
What will be the output of the following Java program? import java.util.*; class LOCALE_CLASS { public static void main(String args[]) { Locale obj = new Locale("HINDI", "INDIA") ; System.out.print(obj.getCountry()); } }
Q7
toRadian() and toDegree() methods were added by which version of Java?
Q8
Math.random() guarantees uniqueness?
Q9
Which of these methods return string equivalent of Boolean object?
Q10
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("Box #" + counter + " contains [" + boxContents.toString() + "]"); counter++; } } public static void main(String[] args) { java.util.ArrayList<Box<Integer>> listOfIntegerBoxes = new java.util.ArrayList<>(); BoxDemo.<Integer>addBox(Integer.valueOf(10), listOfIntegerBoxes); BoxDemo.outputBoxes(listOfIntegerBoxes); } }
Q11
Which of these package is used for graphical user interface?
Q12
Which of these methods initiates garbage collection?
Q13
What will be the output of the following Java program? class Output { public static void main(String args[]) { double x = 102; double y = 5; double z = Math.IEEEremainder(x, y); System.out.print(z);} } }
Q14
Which of the following is a method of wrapper Float for converting the value of an object into byte?
Q15
Does code Segment loads the java code?
Q16
What will be the output of the following Java code? class Output { public static void main(String args[]) { Double y = new Double(257.57812); Double i = new Double(257.578123456789); try { int x = i.compareTo(y); System.out.print(x); } catch(ClassCastException e) { System.out.print("Exception"); } } }
Q17
What will be the output of the following Java program? package pkg; class output { public static void main(String args[]) { StringBuffer s1 = new StringBuffer("Hello World"); s1.insert(6 , "Good "); System.out.println(s1); } } Note : Output.class file is not in directory pkg.
Q18
How to read a classpath file?
Q19
Which of these methods return a class object given its name?
Q20
Which of these interface is not a member of java.io package?
Q21
Which of these class is used to make a thread?
Q22
What will be the output of the following Java program? (Note: inputoutput.java is stored in the disk.) import java.io.*; class filesinputoutput { public static void main(String args[]) { InputStream obj = new FileInputStream("inputoutput.java"); System.out.print(obj.available()); } }
Q23
Which of these Exceptions is thrown by loadClass() method of ClassLoader class?
Q24
What will be the output of the following Java program? import java.io.*; public class filesinputoutput { public static void main(String[] args) { String obj = "abc"; byte b[] = obj.getBytes(); ByteArrayInputStream obj1 = new ByteArrayInputStream(b); for (int i = 0; i < 2; ++ i) { int c; while ((c = obj1.read()) != -1) { if (i == 0) { System.out.print(Character.toUpperCase((char)c)); } } } } }
Q25
What will be the output of the following Java program? interface calculate { void cal(int item); } class displayA implements calculate { int x; public void cal(int item) { x = item * item; } } class displayB implements calculate { int x; public void cal(int item) { x = item / item; } } class interfaces { public static void main(String args[]) { displayA arr1 = new displayA; displayB arr2 = new displayB; arr1.x = 0; arr2.x = 0; arr1.cal(2); arr2.cal(2); System.out.print(arr1.x + " " + arr2.x); } }