This is a interview test for a Java programmer at an advanced level. There are 10 questions but more than a single answer to most of the questions. The correct answers are given at the end of the article together with the points awarded for each correct option and the difficulty of the question on a 1-10 scale. The best score you can get is 100 by answering correctly to all questions.
1. Question : Language Features - OO rules
What is going to happen when the following program executes?
class A {
public void a() {
b();
}
private void b() {
System.out.println(“Executing A’s b()”);
}
}
class B extends A {
public void b() {
System.out.println(“Executing B’s b()”);
}
}
…
public static void main(String[] argv) {
B b = new B();
b.b();
b.a();
}
1. B’s b() will run and then A’s b() will run
2. A’s b() is going to be called twice
3. B’s b() is going to be called twice
4. A’s b() will run and the B’s b() will run
5. The compiler will not allow the above code to compile
2. Question : APIs - Swing
Swing Components can change their look and feel (l&F) at runtime.
Which of the l&f come standard with swing?
1. macintosh l&f
2. metal l&f
3. motif l&f
4. windows l&f
5. vax l&f
3. Question : VM Architecture : Parts and Design
Which of the following statements concerning the Virtual Machine are true and which are false?
1. Object are stored in the heap, local variables are stored in the stack.
2. The Virtual Machine has 8 registers, each one has the length of one word.
3. The Virtual Machine does not differentiate between an instance method and a constructor method.
4. A StackFrame gets created into the VM’s stack area for every thread executed.
5. The VM keeps a program counter for every thread.
4. Question : VM Architecture : Performance
Which of the following statements concerning performance are true and which are false?
1. Methods called through an interface reference are slower than those called through abstract methods because they can never be pointed directly by fields in the class pool of the caller
2. The invocation of an interface method is slower than Instantiation
3. The statement x = 3 executes faster than the statement x = 15.
4. Hotspot compilers convert all the bytecode into native code at runtime
5. Polymorphic calls are almost as fast as static method calls.
5. Question : Language Features - Classloaders
When two objects loaded through different Classloaders can they communicate?
1. When the invoker object access the other object through an interface that has been loaded using the invoker object’s classloader.
2. When they belong to the same package
3. When the invoker’s classloader has resolved the class of the other object
4. When the Security Manager allows it
5. Never, objects loaded using different Classloaders can’t communicate.
6. Question : Language Features - Reflection
Which of the following are valid ways of making an instance from class X
1. X myX = new X();
2. X myX = (X)((X.class).newInstance())
3. X myX = (X)Class.instantiate(X);
4. X myX = (X)(X.class).getClass().forName(”X”).newInstance();
5. X myX = (X)(Class.forName(”X”)).newInstance())
7. Question : Language Tools - Debuggers - Dissassemblers - Profilers
Which of the following statements are true and which are false?
1. JPDA stands for Java Personal Digital Assistant
2. SerVer is a jdk tool that allows serial verification of test profiles
3. The 4 first bytes on the header of any valid class file says JAVABABE
4. The bytecode form of a program can’t store the identifier names
5. Changing a String value of a bytecode class file will damage the file and render it unloadable.
8. Question : Object Orientation Principles - Patterns Basic
What is the pattern that best expresses the relationship between AWT’s classes Component and Container?
1. Factory
2. Strategy
3. Composite
4. Decorator
5. Proxy
9. Question : Object Orientation Principles - Patterns Advanced
Which of the following statements concerning the use of design patterns into the various java API’s are true and which are false?
1. An AWT’s Toolkit plays the role of an “Abstract Factory”
2. The LayoutManager in AWT plays the role of a “Decorator”
3. The Enumeration Interface reveals actually a “Mediator”
4. A Point in AWT is a “Wrapper”
5. A File is implemented in java using the “Composite” pattern
10. Question : Java API Design
The implementation of which design pattern would significantly improve the layout mechanism in terms of simplicity and readability?
1. State
2. Singleton
3. Null Object
4. Decorator
5. Facade
Answer : 1 = true
Grading : 10 points for the correct answer
Difficulty : 9/10 A.
2. Answer to Question 2:
Answer : 2 = true, 3 = true, 4=true
Grading : 10 points for all the correct answers
Difficulty : 1/10 A.
3. Answer to Question 3:
Answer : 1 = true, 2 = false, 3 = false, 4 = false, 5 = true
Grading : 2 points per correct answer
Difficulty : 4/10 A.
4. Answer to Question 4:
Answer : 1 = true, 2 = false, 3 = true, 4 = false, 5 = false
Grading : 2 points per correct answer
Difficulty : 8/10 A.
5. Answer to Question 5:
Answer : 1 = true
Grading : 10 points for the correct answer
Rational : This question assesses the delegate’s understanding of
Difficulty : 8/10 A.
6. Answer to Question 6:
Answer : 1 = true, 2 = true, 3 = false, 4 = true, 5 = true
Grading : 10 points for giving all four correct answers
Difficulty : 5/10 A.
7. Answer to Question 7:
Answer : 1 = false, 2 = false, 3 = false, 4 = false, 5 = false
Grading : 2 points for every correct answer
Difficulty : 1/10 A.
8. Answer to Question 8:
Answer :3 = true
Grading :10 points for correct answer
Difficulty : 4/10 A.
9. Answer to Question 9:
Answer : 1 = true, 2 = false, 3 = false, 4 = false, 5 = false
Grading : 2 points for every correct answer
Difficulty : 10/10 A.
10. Answer to Question 10:
Answer : 3 = true
Grading : Grading: 10 points for correct answer
Difficulty : 10/10 A.
No comments:
Post a Comment