JavaBeat
SCJP 5.0 Home New to SCJP? Objectives Articles Mock Exams Tutorials Resources SiteMap & Links Forums  

SCJP 5.0 Questions
01. MockExam - 01
02. MockExam - 02
03. MockExam - 03
04. AutoBoxing - 1 (10 questions)
05. AutoBoxing - 2 (10 questions)
06. Generics 1 - 6 Questions
07. Generics 2 - 7 Questions
08. Generics 3 - 10 Questions
09. Generics 4 - 10 Questions
10. Generics 5 - 10 Questions
11. Generics 6 - 10 Questions
12. Enum 1 - 10 Questions
13. Enums 2 - 10 Questions
14. Enums 3 - 15 Questions
15. Var Args 1 - 10 Questions
16. Var Args 2 - 10 Questions
17. SCJP 5.0 Mock Questions -1
18. Declaration,Access Control-1
19.Java File IO Package - 1
20.Java File IO Package - 2
21.Language Features - 1
22.New Api's - 1 (10 questions)
23.New Api's - 2 (12 questions)
24.Objective - 1 (20 questions)
25.Objective - 2 (10 questions)
26.Objective - 3 (10 questions)
27.Objective - 4 (10 questions)
28.Objective - 5 (10 questions)
29.Objective - 6 (10 questions)
30.Objective - 7 (10 questions)
350 Mock Questions on SCJP 1.5 - JUST Rs.200 or 7 USD
Send us mail to sales@javabeat.net
more details
Do you have paypal account? Click Here to pay now and get the questions.

SCJP 1.5 Generics Mock Exam Questions - 6

4) Which of the following statements hold true in the following program?


package generics;
import java.util.ArrayList;
import java.util.List;
public class Ques04 {
	public static void main(String[] args) {
		List<? extends Instrument> allInstruments = new ArrayList<Instrument>(); 
		// -->X
		allInstruments.add(new Guitar());
		allInstruments.add(new Violin());
	}
}
interface Instrument {
	public void play();
}
class Guitar implements Instrument {
	public void play(){
		System.out.println("Playing Guitar.");
	}
}
class Violin implements Instrument {
	public void play(){
		System.out.println("Playing Violin.");
	}
}
1. The program will not compile.
2. The program will compile but will throw run-time exception.
3. The statement 'X' manifests that objects of type Instrument as well as sub-types can be added to the list 'allInstruments'.
4. It is not possible to add any type of objects to the list 'allInstruments'.
5. The only possible element that can be added to the list 'allInstruments' is 'null'.

Answer

4) 1,5.
The declaration 'allInstruments' manifests a list, whose reference can point to a similar declaration of list holding Instrument objects or sub-class of Instrument objects. It is not possible to add elements into the list 'allInstruments'. The only permissible allowed type is 'null'.

Get more questions on generics and SCJP 1.5 topics

350 Mock Questions on SCJP 1.5 - JUST Rs.200 or 7 USD
Send us mail to sales@javabeat.net
more details

Sponsors
Webmaster Hosting Forum
Java Jobs
Latest in DLinks
http://javawave.blogspot.com/2008/04/quartz-job-scheduler-part-ii-example.html
Quartz Job Scheduler -- Part 1 (Setting up development project in Netbeans 6.1 beta)
Flex Messaging with BEA Workshop Studio
SOA and Virtualization: How do They Fit Together?
Introduction to Enterprise Portals - Why they Benefit IT and the Business
BEA WebLogic Operations Control: Application Virtualization for Enterprise Java
Best Practices for Building Production Quality EAR Files
BEA's SOA Reference Architecture - A Foundation for Business Agility
Blueprint for Successful SOA Integration
Guardian - What a tool!

JavaBeat Media (2004-2008), India
javabeat home | About Us
our network : opensource softwares
Copyright © 2007 JavaBeat