IntelliJ Java IDE
The moose likes Associate Certification (SCJA/OCAJ) and the fly likes Objecttive 1.5 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Associate Certification (SCJA/OCAJ)
Reply Bookmark "Objecttive 1.5" Watch "Objecttive 1.5" New topic
Author

Objecttive 1.5

Paulo Aquino
Ranch Hand

Joined: Apr 29, 2002
Posts: 199
In this objective, it ws mentioned that exam takers should know how to describe and apply the "program to an interface" principle. Can anyone shed light to this principle?


Be Afraid...Be very Afraid...
Dave Wood
bronco
Ranch Hand

Joined: Aug 02, 2004
Posts: 161
If you have a copy of Design Patterns handy (and if you don't, you SHOULD!), read pages 17-18 for a discussion of this topic.

In a nutshell:


Don't declare variables to be instances of particular concrete classes. Instead, commit only to an interface defined by an abstract class (Dave comment: or interface).


Note that this concept is not literally talking about Java interfaces (in the DP book, which is generally C++ oriented, they just talk about abstract classes), though they certainly apply.

There are not a lot of exam questions on this topic. You just need to understand the basic idea. For example:

HashMap hm = new HashMap(); // not programming to an interface

vs.

Map map = someFactory.createMap(); // programming to an interface

HTH,
Dave


Co-Author of <a href="http://www.oreilly.com/catalog/jswing2" target="_blank" rel="nofollow">Java Swing</a><br />Co-Creator of <a href="http://www.sun.com/training/catalog/courses/CX-310-055.xml" target="_blank" rel="nofollow">SCJP 5.0</a> and <a href="http://www.sun.com/training/certification/java/associate_beta.xml" target="_blank" rel="nofollow">SCJA</a> exams
Mahesh Kumaraguru
Ranch Hand

Joined: Jun 01, 2005
Posts: 95
Originally posted by Paulo Aquino:
In this objective, it ws mentioned that exam takers should know how to describe and apply the "program to an interface" principle. Can anyone shed light to this principle?


"Program to an interface" is discussed with examples at

http://www.coderanch.com/t/178299/java-SCJA/certification/describe-apply-program-interface-principle


Regards,<br />K. Mahesh<br /> <br />SCJP 1.2 Aug-2001 : 79%
 
 
subject: Objecttive 1.5
 
Threads others viewed
how exception is handled in constructor
Question related Typecasting in Generics
threads and uncaught exceptions
Limiting Scope of a Change
Weaker Access Privilege
developer file tools