Quiz on Java Wildcard
Free Java courses with 37 real-time projects - Learn Java
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 15 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Categories
- Not categorized 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
- Question 1 of 15
1. Question
Which type of wildcard should be used to relax the data type restriction ?
CorrectIncorrect - Question 2 of 15
2. Question
class Main {
public static void main ( String args [ ] )
{
List<String> list = Arrays.aslist(“Sunday”,”Monday”,”Tuesday”);
print(list);
List<Object> list2 = Arrays.aslist(“Sunday”,”Monday”,”Tuesday”);
print(list2);
public static void print(List<?extend numbers> list)
{
System.out.println(list);
}
}
}
What will be the output of the program ?
CorrectIncorrect - Question 3 of 15
3. Question
class WildCard {
public static void main ( String args [ ] )
{
List < int > list1 = Arrays.aslist(1,2,3,4,5);
show(list);
List <String> list2 = Arrays.aslist(“One”,”two”,”three”,”four”,”five”);
show(list2);
public static void show(List<?> list)
{
System.out.println(list);
}
}
}
What is the output of the program ?
CorrectIncorrect - Question 4 of 15
4. Question
Which are the things used to decide the type of wildcard for the program ?
CorrectIncorrect - Question 5 of 15
5. Question
Which of the following is the correct syntax of Unbounded wildcards in Java ?
CorrectIncorrect - Question 6 of 15
6. Question
class Unbounded {
public static void main ( String args [ ] )
{
List<Object> array1 = new ArrayList(“Integer”,”String”,”Character”);
print(array1);
List<Object> array2 = new ArrayList(1 , 10 , 11 , 10 , 12 , 20 );
print(array2);
public static void print(List < ? > list)
{
System.out.println(list);
}
}
}
What is the output of the program ?
CorrectIncorrect - Question 7 of 15
7. Question
Which of the following is not a correct syntax for using wildcards in java ?
CorrectIncorrect - Question 8 of 15
8. Question
class Addition {
public static void main ( String args [ ] )
{
List < Integer > l1 = new ArrayList(10,8,6,4,2);
add(l1);
public static void add(List < ? extends Number > list)
{
int sum=0;
for( Number i : l1)
{
sum = sum+i;
}
system.out.println(sum);
}
}
What is the output of the program ?
CorrectIncorrect - Question 9 of 15
9. Question
class LowerBound {
public static void main ( String args [ ] )
{
List<Integer> l1 = Arrays.aslist(10,20,30,40,50);
display(l1);
List <Number> l2 = Arrays.aslist(10.00,20.00,30.00,40.00,50.00);
public static void display(List<?super>list)
{
System.out.println(list);
}
}
}
What is the output of the program ?
CorrectIncorrect - Question 10 of 15
10. Question
Super keyword is used in which of the following wildcards ?
CorrectIncorrect - Question 11 of 15
11. Question
class Main {
public static void main ( String args [ ] )
{
List < Object > list1 = new Arraylist(“String”,1,’c’);
print(list1);
List<Integer> list2 = new ArrayList(2 , 3, 6 , 18 , 108 );
print(list2);
public static void print(List<?> list)
{
System.out.println(list);
}
}
}
What is the output of the program ?
CorrectIncorrect - Question 12 of 15
12. Question
class Numbers {
public static void main ( String args [ ] )
{
List < Integer > l1 = new ArrayList(25 , 75 , 125 , 175 , 225 , 275 , 325);
add(l1);
public static void add(List < ? extends Number > list)
{
System.out.println(l1.size());
}
}
}
What is the output of the program ?
CorrectIncorrect - Question 13 of 15
13. Question
Which variable can be an in variable in Java ?
CorrectIncorrect - Question 14 of 15
14. Question
Which of the following is the correct syntax of Lower bound wildcards in Java ?
CorrectIncorrect - Question 15 of 15
15. Question
class Main {
public static void main ( String args [ ] )
{
List<Integer> array1 = Array.mylist(10,100,1000,10000,100000);
message(array1);
List<Double> array2 = Array.mylist(1.1,1.11,1.111,1.1111,1.11111);
text(array2);
public static void text( List < ? super > list )
{
System.out.println(list);
}
}
}
What is the error in the program ?
CorrectIncorrect
Did you know we work 24x7 to provide you best tutorials
Please encourage us - write a review on Google