Dan Chisholm's
Java Programmer Certification Mock Exam

Please Help Save a Tree!

The pages of this web site are not formatted to conserve paper, but my new book (ISBN: 0-9745862-0-X) is formatted to save paper, save your printer cartridge, save a loose-leaf binder, and save money. If you prefer to work my exams from printed pages, then give your printer a rest and buy my new book.

Today, you can find my book at BookSurge.com.

Are you a university student studying Java programming? Do you agree that my book would serve as a helpful workbook and companion to be used along with the Java fundamentals textbook that is currently being used in your class? If so, then please ask your professor to consider using my book in future classes.

If you have any questions or comments concerning my mock exams or my book, then please send an e-mail to me at scjpexam2000@yahoo.com.

I would also like to read your response to the following questions.

Answers: Java Programmer Certification Mock Exam
No.AnswerRemark
1a  c  e  A nested class is any class that is declared within the body of another class or interface.  An inner class is a nested class that is not static.  A named class is any class that is not anonymous.  Every class declared within the body of another class or interface is known as a nested class. If the nested class does not have a name, then it is an anonymous class. If the nested class has a name, then it is not anonymous. If the nested class has a name and is not declared inside of a method, constructor or any block, then it is a member class. If a member class is not static, then it is an inner class. If a class is not nested, then it is a top level class. A nested class that is static is sometimes referred to as a top level class, but that usage of the term is confusing and should be avoided.  
2a  c  e  A local class is declared within a method, constructor or block.  A local class is a nested class.  A local class is always a named class.  Every class declared within the body of another class is known as a nested class. If the nested class does not have a name, then it is an anonymous class. If the nested class has a name, then it is not anonymous. If the nested class has a name and is declared inside of a method, constructor or any block, then it is a local class. If a nested class does not have a name, then it can not be called a local class even if it is declared inside of a block. Therefore, an anonymous class is never called a local class. If the nested class has a name and is not declared inside of a method, constructor or any block, then it is a member class. If the class is not nested, then it is a top level class. Please note that this question is more rigorous than those that one might expect to find on the real exam. It has been included here as a convenient place to define some terms that are used to explain the answers to some of the other questions that appear in this mock exam.  
3a  c  e  f  g  h  abstract  final  private  protected  public  static  The access modifiers, public, protected and private, can not be applied to a local class. The protected and private access modifiers can be applied to member classes, but not to a top level class. The public modifier can be applied to a top level class or a member class, but not a local class. The static modifier can be applied to a member class, but not to a local class or top level class. The keywords extends and implements are not modifiers. The synchronized modifier can be applied to a method, but not to a class. The modifiers, transient and volatile, can be applied to a field, but not to a class.  
4a  b  c  d  e  f  abstract  final  public  protected  private  static  A nested class that has a name and is not a local class is a member class. A member class can be static or non-static. A non-static member class is also known as an inner class. All of the class modifiers may be applied to a member class. The modifiers, synchronized and transient, are not class modifiers.  
5d  f  abstract  final  If a nested class has a name and is declared inside of a method, constructor or any block, then it is a local class. No access modifier can be applied to a local class declaration. A local class can not be static. A local class can be abstract, and can be final.  
6None of the above  The following modifiers can be applied to a member class: abstract, private, protected, public, static and final.  
7 Please note that this question asks which class declaration does NOT result in a compile-time error. The following modifiers can be applied to a member class: abstract, private, protected, public, static and final. The synchronized modifier can not be applied to any class, because it is a method modifier. The modifiers, transient and volatile, can not be applied to any class, because they are field modifiers.  
8c  d  e  The abstract and final modifiers can be applied to a method local class declaration.  
9a  b  c  d  The modifiers, abstract and final, can be applied to a method local class declaration. The synchronized modifier can not be applied to a class, because it is a method modifier. The modifiers, transient and volatile, can not be applied to any class, because they are field modifiers.  
10 A method and a field can share the same name, because they are used in different contexts and use different lookup procedures. They can even share the same name with the class in which they are declared. Please note that class names usually begin with an upper case letter while method and field names usually begin with a lower case letter. A nested class can not share the same name with its enclosing class.  
11None of the above  A method, field, and a nested class can share the same name, because they are used in different contexts and use different lookup procedures. Please note that class names usually begin with an upper case letter while method and field names usually begin with a lower case letter. Also note that a nested class can not share the same name with its enclosing class; however, a method and field can share a name with the enclosing class. Even so, it is not a good idea to name a method with the name of the enclosing class, because it could be confused with a constructor.  
12 An abstract method has no implementation, and is not useful until an extending class implements the method. Private methods are not inherited and can not be overridden. If an abstract method is declared private, then it can not be implemented in a subclass. Although a method may not be both private and abstract, a nested class can be; because another nested class can extend the abstract class and implement any abstract methods.  
13 Please note that this question asks which line does NOT result in a compile-time error. An abstract method has no implementation and is not useful until an extending class implements the method. A final method can not be overridden by a subclass method. An abstract final method can not be implemented and is not legal. An abstract class may contain abstract method declarations and is assumed to be incomplete. A final class can not be extended. The implementation of an abstract final class could not be completed. The declaration of class C results in a compiler error, because a final class may not be listed in the extends clause.  
14 Please note that this question asks which line does NOT result in a compile-time error. The modifier, synchronized, is a method modifier, but is not a class modifier. Any attempt to declare a synchronized class results in a compile-time error. Since the synchronized modifier specifies an implementation detail it makes no sense to use it with an abstract method that provides no implementation.  
 
Ask a Question
Send an email to me.
 
Java Question and Answer Forums
JavaRanch Big Moose Saloon
Marcus Green's Discussion Forum
java.sun.com Forums, Chat and User Groups
 
Other Resources
Java Language Specification
Java Virtual Machine Specification
Java 2 Platform, Standard Edition, v 1.4.0 API Specification
 
Tutorials
Learning the Java Language
Operator Precedence Chart, Expressions, Statements, Blocks
Programming with Assertions
 

Copyright © 2002-2004, Dan Chisholm
All rights reserved.