aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes a bunch of questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "a bunch of questions" Watch "a bunch of questions" New topic
Author

a bunch of questions

Kevin Tysen
Ranch Hand

Joined: Oct 12, 2005
Posts: 255
Studying for the test (Java 7) and looking at the objectives. Don't know these terms so just asking.

According to the regex API, \b is a word boundary and \B is a non-word boundary. But don't know what that means exactly or how to use them.

What's "virtual method invocation"?

In "Object-Oriented Design Principles", it says "Apply object composition principles." What does that mean?

What's the "Singleton design pattern"?

What's the "DAO pattern"?

"Design and create objects using a factory" Does that refer to a factory method, like DateFormat.getInstance() ?
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3647
    
  17

Kevin Tysen wrote:According to the regex API, \b is a word boundary and \B is a non-word boundary. But don't know what that means exactly or how to use them.


It means they match to "zero width" parts of the input string, right before or after a word for \b, or otherwise for \B. For instance in the input string "hello world", \b would match at locations 0, 5, 6 and 11, and \B at everything else.

What's "virtual method invocation"?


I believe it refers to a method call in your code, without knowing exactly which method is going to get called until the moment at runtime where the invocation is actually performed. In Java, this is the case with overridden methods. For instance, when you call toString() on an object, you don't actually know if Object.toString() is going to get called, or maybe Subclass.toString(), or maybe even SubSubClass.toString().

In "Object-Oriented Design Principles", it says "Apply object composition principles." What does that mean?


Lots of beginners extend a class when they believe that their class should provide a lot of the same functions, or maybe they extend a class just because they think it's easy. The truth is that you should rarely have need to extend a class at all. Object composition means that instead of extending a class because you need its functions, you keep a member field referencing it instead.

What's the "Singleton design pattern"?


The Singleton pattern is a pattern where you make a class so it can only have one instance at any given time, and this instance is available globally. It should be used rarely, because global state (static fields) give lots of opportunities to introduce bugs in your program.

What's the "DAO pattern"?


I don't know exactly, I believe it stands for Data Access Object, and it refers to making objects out of entries usually found in databases, to manipulate them more easily. Do a Google search.

"Design and create objects using a factory" Does that refer to a factory method, like DateFormat.getInstance() ?


A factory is an object that exists for the creation of other objects. An example is the ThreadFactory class in java.util.concurrent. A factory method is a method that's responsible for returning instances of a particular type, usually the same type that contains the factory method. I rarely use factory methods, except for types that by nature have a limited amount of distinct instances (value objects). This enables you to force this limitation, and possibly even add caching. I've never designed a factory myself, only utility classes that contain a bunch of factory methods. An example: My Sudokus class that had createSudoku(), createXSudoku(), createSamuraiSudoku() methods, etc.

"Design and create objects using a factory" sounds like a very silly thing to preach as a hard and fast rule. It really depends on the situation.
Kevin Tysen
Ranch Hand

Joined: Oct 12, 2005
Posts: 255
Thank you! That really helps!
Andy James
Ranch Hand

Joined: Aug 22, 2005
Posts: 90
Since the OCP Java SE 7 exam objective mentions "Apply object composition principles", does it refer to multiple principles or just one - "favor composition over inheritance".

cheers
Andy
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: a bunch of questions