Java Questionnaire

(For multiple choice questions, unless otherwise specified, circle all that apply.)

1.) What is the Open-Closed Principle?

a.) Software entities (classes, modules, functions) should be open for extension, but closed for modification.
b.) One should not open classes that others write.
c.) Software entities (classes, modules, functions) should be open for modification, but closed for extension.
d.) The classes in a package should be closed together against the same kinds of changes. A change that affects a package affects all the classes in that package.

2.) Is it good OOD practice to favor composition over inheritance?  Why or why not?

Oop design principles states some of the principles one of it is "favor composition over inheritance".   Both composition and inheritance are important methods of reuse Inheritance was overused in the early days of OO development.  Over time we've learned that designs can be made more reusable and simpler by favoring composition

Of course, the available set of composable classes can be enlarged using inheritance.  So composition and inheritance work together.  But our fundamental principle is Favor Composition Over Inheritance

3.) Is it good design practice to program towards an implementation rather than an interface?  Why or why not?

No, it is not good design practice to program towards implementation. Design principle says...

Once you depend on interfaces only, you're decoupled from the implementation. That means the implementation can vary, and that's a healthy dependency relationship.

4.) The _______ pattern centralizes distributed service object lookups, provides a centralized point of control, and may act as a cache that eliminates redundant lookups. It also encapsulates any vendor-specific features of the lookup process.

a.) Dependency Injection
b.) Façade
c.) Service Locator
d.) Template

5.) What does RMI stand for?

Remote method invocation. Java Remote Method Invocation (Java RMI) enables the programmer to create distributed Java technology-based to Java technology-based applications, in which the methods of remote Java objects can be invoked from other Java virtual machines, possibly on different hosts. RMI uses object serialization to marshal and unmarshal parameters and does not truncate types, supporting true object-oriented polymorphism.

6.) What is an "unchecked runtime exception"? Give at least one example.

The exceptions which occur at runtime and not at compile time are called unchecked runtime exceptions. NullPointerException is one such example.

7.) Given an example of a non mutable class?

StringBuffer

8.) What command would you use to list all of the files contained in a jar file?

jar -tf  <NAME OF JAR FILE>

9.) Which of these are legal identifiers. Select the three correct answers. 

a. number_1
b. number_a 
c)  $1234 
d)  -volatile 

10.) Which of the following are keywords in Java. Select the two correct answers. 

a.  friend 
b.  NULL 
c.  implement 
d.  synchronized 
e.  throws 

11.) What does SSH stand for? 

Secured Shell

12.) On a UNIX system what does the command "kill -9 12345" do.  Be specific.

It kills the process with pid 12345 , -9 sends the SIG_KILL signal.

13.)  Is HTTP a state full protocol?

No, it is a stateless protocol, so to maintain the state one need to use Session object or coockies or url rewrite.

*-- Sumant Khapre

More Java Questions

Java Books
Java Certification, Programming, JavaBean and Object Oriented Reference Books

Return to : Java Programming Hints and Tips

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site www.erpgreat.com is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.