ExamVeda
Login
Home
51
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));
    }
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
52
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());
    }
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
53
Which of the following allows us to call generic methods as a normal method?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
54
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());
    }
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
55
Which of these type parameters is used for a generic methods to return and accept any type of object?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
56
Which of the following keywords are used for lower bounding a wild card?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
57
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());
    }
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
58
What is use of wildcards?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
59
Which of these types cannot be used to initiate a generic type?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
60
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());
    }
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board