Question 1 of 25
Hints left: 3
Q1
What is the role of the `javabeans.Introspector` class in JavaBeans?
Q2
What will be the output of the following Java program? import java.util.*; public class genericstack <E> { Stack <E> stk = new Stack <E>(); public void push(E obj) { stk.push(obj); } public E pop() { E obj = stk.pop(); return obj; } } class Output { public static void main(String args[]) { genericstack <Integer> gs = new genericstack<Integer>(); gs.push(36); System.out.println(gs.pop()); } }
Q3
In JavaBeans, what is the purpose of the getter method?
Q4
What will be the output of the following Java program? import java.util.*; class Output { public static double sumOfList(List<? extends Number> list) { double s = 0.0; for (Number n : list) s += n.doubleValue(); return s; } public static void main(String args[]) { List<Integer> li = Arrays.asList(1, 2, 3); System.out.println(sumOfList(li)); } }
Q5
Which of the following cannot be Type parameterized?
Q6
Which of these type parameters is used for a generic methods to return and accept any type of object?
Q7
What will be the output of the following Java code? import java.util.*; public class genericstack <E> { Stack <E> stk = new Stack <E>(); public void push(E obj) { stk.push(obj); } public E pop() { E obj = stk.pop(); return obj; } } class Output { public static void main(String args[]) { genericstack <Integer> gs = new genericstack<Integer>(); gs.push(36); System.out.println(gs.pop()); } }
Q8
Which file extension is commonly used for JavaBean files?
Q9
What will be the output of the following Java program? import java.util.*; class Output { public static double sumOfList(List<? extends Number> list) { double s = 0.0; for (Number n : list) s += n.doubleValue(); return s; } public static void main(String args[]) { List<Double> ld = Arrays.asList(1.2, 2.3, 3.5); System.out.println(sumOfList(ld)); } }
Q10
What does the JDBC `Connection` interface represent?
Q11
What is use of wildcards?
Q12
What will be the output of the following Java code? import java.util.*; public class genericstack <E> { Stack <E> stk = new Stack <E>(); public void push(E obj) { stk.push(obj); } public E pop() { E obj = stk.pop(); return obj; } } class Output { public static void main(String args[]) { genericstack <String> gs = new genericstack<String>(); gs.push("Hello"); System.out.println(gs.pop()); } }
Q13
What will be the output of the following Java program? import java.util.*; public class genericstack <E> { Stack stk = new Stack <E>(); public void push(E obj) { stk.push(obj); } public E pop() { E obj = stk.pop(); return obj; } } class Output { public static void main(String args[]) { genericstack <String> gs = new genericstack(); gs.push("Hello"); System.out.println(gs.pop()); } }
Q14
Which of the following is a valid property name for a JavaBean?
Q15
Which of these types cannot be used to initiate a generic type?
Q16
Which of these type parameters is used for a generic methods to return and accept a number?
Q17
What is JDBC in Java?
Q18
What is the purpose of the JDBC `DriverManager` class?
Q19
Which Java package contains the JDBC classes and interfaces?
Q20
Which of the following keywords are used for lower bounding a wild card?
Q21
What is a JavaBean in Java?
Q22
Which of the following allows us to call generic methods as a normal method?
Q23
Which of these is an correct way of defining generic method?
-
A
-
B
-
C
-
D
Q24
What will be the output of the following Java program? import java.util.*; public class genericstack <E> { Stack <E> stk = new Stack <E>(); public void push(E obj) { stk.push(obj); } public E pop() { E obj = stk.pop(); return obj; } } class Output { public static void main(String args[]) { genericstack <Integer> gs = new genericstack<Integer>(); gs.push(36); System.out.println(gs.pop()); } }
Q25
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); } }