Saturday, November 28, 2009

Best Java Question

Difference between JDK1.4.2, JDK 1.5.0 and JDK1.6


JDK 1.0 (january 23, 1996) oak

- Initial release

JDK 1.1 (february 19, 1997)

- Retooling of the AWT event model
- Inner classes added to the language
- JavaBeans
- JDBC
- RMI


J2SE 1.2 (December 8, 1998) playground

This and subsequent releases through J2SE 5.0 were rebranded retrospectively Java 2 & version name "J2SE" (Java 2 platform, Standard edition) replaced JDK to distinguish the base platform from J2EE (java 2 platform, enterprise edition) and J2ME (java 2 platform, micro edition).

- Strictfp keyword
- Reflection
- Swing api integration into the core classes
- JVM equipped with a jit compiler
- Java plug-in
- Java IDL
- An IDL implementation for corba interoperability
- Collections Framework


J2SE 1.3 (may 8, 2000) kestrel

- Hotspot jvm included
- JavaSound
- JNDI included in core libraries
- Java platform debugger architecture (jpda)
- RMI was modified to support optional compatibility with corba


J2SE 1.4 (february 6, 2002) merlin

- assert keyword
- Regular expressions
- Exception chaining (allows an exception to encapsulate original lower-level exception)
- Internet protocol version 6 (IPV6) support
- Non-blocking nio (new input/output)
- Logging API
- Image i/o api for reading and writing images in formats like jpeg and png
- Integrated XML parser and XSLT processor (JAXP)
- Integrated security and cryptography extensions (JCE, JSSE, JAAS)
- Java web start


J2SE 5.0 (september 30, 2004) tiger [originally numbered 1.5]

- Generics: provides compile-time (static) type safety for collections and eliminates the need for most typecasts (type conversion).
- Metadata: also called annotations; allows language constructs such as classes and methods to be tagged with additional data, which can then be processed by metadata-aware utilities.
- Autoboxing/unboxing: automatic conversions between primitive types (such as int) and primitive wrapper classes (such as integer).
- Enumerations: the enum keyword creates a typesafe, ordered list of values (such as day.monday, day.tuesday, etc.). Previously this could only be achieved by non-typesafe constant integers or manually constructed classes (typesafe enum pattern).
- Swing: new skinnable look and feel, called synth.
- Var args: the last parameter of a method can now be declared using a type name followed by three dots (e.g. Void drawtext(string... Lines)). In the calling code any number of parameters of that type can be used and they are then placed in an array to be passed to the method, or alternatively the calling code can pass an array of that type.
- Enhanced for each loop: the for loop syntax is extended with special syntax for iterating over each member of either an array or any iterable, such as the standard collection classesfix the previously broken semantics of the java memory model, which defines how threads interact through memory.
- Automatic stub generation for rmi objects.
- Static imports concurrency utilities in package java.util.concurrent.
- Scanner class for parsing data from various input streams and buffers.
- Assertions
- StringBuilder class (in java.lang package)
- Annotations


Java SE 6 (december 11, 2006) mustang

sun replaced the name "J2SE" with java se and dropped the ".0" from the version number. Beta versions were released in february and june 2006, leading up to a final release that occurred on december 11, 2006.

The current revision is update 14 which was released in may 2009.

- Support for older win9x versions dropped.
- Scripting lang support: Generic API for integration with scripting languages, & built-in mozilla javascript rhino integration
- Dramatic performance improvements for the core platform, and swing.
- Improved web service support through JAX-WS JDBC 4.0 support
- Java compiler API: an API allowing a java program to select and invoke a java compiler programmatically.
- Upgrade of JAXB to version 2.0: including integration of a stax parser.
- Support for pluggable annotations
- Many GUI improvements, such as integration of swingworker in the API, table sorting and filtering, and true swing double-buffering (eliminating the gray-area effect).





Java se 6 update 10
A major enhancement in terms of end-user usability.
- Java Deployment Toolkit, a set of javascript functions to ease the deployment of applets and java web start applications.
- Java Kernel, a small installer including only the most commonly used jre classes. Enhanced updater.
- Enhanced versioning and pack200 support: server-side support is no longer required.
- Java quick starter, to improve cold start-up time.
- Improved performance of java2D graphics primitives on windows, using direct3D and hardware acceleration.
- A new Swing look and feel called NIMBUS and based on synth.
- Next-generation java plug-in: applets now run in a separate process and support many features of web start applications.

Java se 6 update 12
This release includes the highly anticipated 64-bit java plug-in (for 64-bit browsers only), windows server 2008 support,
and performance improvements of java and JAVAFX applications.



**************************************

Sun Certified Programmer for the Java 2
Platform, Standard
Exam 310-055



Question 1
Given:
11. public interface Status {
12. /* insert code here */ int MY_VALUE = 10;
13. }
Which three are valid on line 12? (Choose three.)
A. final
B. static
C. native
D. public
E. private
F. abstract
G. protected
Answer: ABD
Question 2
Given:
10. public class Bar {
11.static void foo(int...x) {
12. // insert code here
13. }
14. }
Which two code fragments, inserted independently at line 12, will allow
the class to compile? (Choose two.)
A. foreach(x) System.out.println(z);
B. for(int z : x) System.out.println(z);
C. while( x.hasNext()) System.out.println( x.next());
D. for( int i=0; i< x.length; i++ ) System.out.println(x[i]);
Answer: BD
Question 3
Given:
11. public class Test {
12. public static void main(String [] args) {
13. int x =5;
14. boolean b1 = true;
15. boolean b2 = false;
16.
17.if((x==4) && !b2)
18. System.out.print(”l “);
19. System.out.print(”2 “);
20. if ((b2 = true) && b1)
21. System.out.print(”3 “);
22. }
23. }
What is the result?
A. 2
B. 3
C. 1 2
D. 2 3
E. 1 2 3
F. Compilation fails.
G. Au exceptional is thrown at runtime.
Answer: D
Question 4
4. Given:
31. // some code here
32. try {
33. // some code here
34. } catch (SomeException se) {
35. // some code here
36. } finally {
37. // some code here
38. }
Under which three circumstances will the code on line 37 be executed?
(Choose three.)
A. The instance gets garbage collected.
B. The code on line 33 throws an exception.
C. The code on line 35 throws an exception.
D. The code on line 31 throws an exception.
E. The code on line 33 executes successfully.
Answer: BCE
Question 5
Given:
10. interface Foo {}
11. class Alpha implements Foo { }
12. class Beta extends Alpha {}
13. class Delta extends Beta {
14. public static void main( String[] args) {
15. Beta x = new Beta();
16. // insert code here
17. }
18. }
Which code, inserted at line 16, will cause a
java.lang.ClassCastException?
A. Alpha a = x;
B. Foo f= (Delta)x;
C. Foo f= (Alpha)x;
D. Beta b = (Beta)(Alpha)x;
Answer: B
Question 6
Given:
• d is a valid, non-null Date object
• df is a valid, non-null DateFormat object set to the
current locale
What outputs the current locales country name and the appropriate
version of d’s date?
A. Locale loc = Locale.getLocale();
System.out.println(loc.getDisplayCountry()
+ “ “+ df.format(d));
B. Locale loc = Locale.getDefault();
System.out.println(loc.getDisplayCountry()
+ “ “ + df.format(d));
C. Locale bc = Locale.getLocale();
System.out.println(loc.getDisplayCountry()
+ “ “+ df.setDateFormat(d));
D. Locale loc = Locale.getDefault();
System.out.println(loc.getDispbayCountry()
+ “ “+ df.setDateFormat(d));
Answer: B
Question 7
Given:
20. public class CreditCard {
21.
22. private String cardlD;
23. private Integer limit;
24. public String ownerName;
25.
26. public void setCardlnformation(String cardlD,
27. String ownerName,
28. Integer limit) {
29. this.cardlD = cardlD;
30. this.ownerName = ownerName;
31. this.limit = limit;
32. }
33. }
Which is true?
A. The class is fully encapsulated.
B. The code demonstrates polymorphism.
C. The ownerName variable breaks encapsulation.
D. The cardlD and limit variables break polymorphism.
E. The setCardlnformation method breaks encapsulation.
Answer: C
Question 8
Assume that country is set for each class.
Given:
10. public class Money {
11. private String country, name;
12. public getCountry() { return country; }
13.}
and:
24. class Yen extends Money {
25. public String getCountry() { return super.country; }
26. }
27.
28. class Euro extends Money {
29. public String getCountry(String timeZone) {
30. return super.getCountry();
31. }
32. }
Which two are correct? (Choose two.)
A. Yen returns correct values.
B. Euro returns correct values.
C. An exception is thrown at runtime.
D. Yen and Euro both return correct values.
E. Compilation fails because of an error at line 25.
F. Compilation fails because of an error at line 30.
Answer: BE
Question 9
Which Man class properly represents the relationship “Man has a best
friend who is a Dog”?
A. class Man extends Dog { }
B. class Man implements Dog { }
C. class Man { private BestFriend dog; }
D. class Man { private Dog bestFriend; }
E. class Man { private Dog }
F. class Man { private BestFriend }
Answer: D
Question 10
Given:
11. public class Person {
12. private name;
13. public Person(String name) {
14. this.name = name;
15. }
16. public int hashCode() {
17. return 420;
18. }
19. }
Which is true?
A. The time to find the value from HashMap with a Person key depends
on the size of the map.
B. Deleting a Person key from a HashMap will delete all map entries for
all keys of type Person.
C. Inserting a second Person object into a HashSet will cause the first
Person object to be removed as a duplicate.
D. The time to determine whether a Person object is contained in a
HashSet is constant and does NOT depend on the size of the map.
Answer: A
Question 11
Given:
23. Object [] myObjects = {
24. new integer(12),
25. new String(”foo”),
26. new integer(5),
27. new Boolean(true)
28. };
29. Arrays.sort(myObjects);
30. for( int i=0; i31. System.out.print(myObjects[i].toString());
32. System.out.print(” “);
33. }
What is the result?
A. Compilation fails due to an error in line 23.
B. Compilation fails due to an error in line 29.
C. A ClassCastException occurs in line 29.
D. A ClassCastException occurs in line 31.
E. The value of all four objects prints in natural order.
Answer: C
Question 12
12. Given:
13. public class Pass {
14. public static void main(String [1 args) {
15. int x 5;
16. Pass p = new Pass();
17. p.doStuff(x);
18. System.out.print(” main x = “+ x);
19. }
20.
21. void doStuff(int x) {
22. System.out.print(” doStuff x = “+ x++);
23. }
24. }
What is the result?
A. Compilation fails.
B. An exception is thrown at runtime.
C. doStuffx = 6 main x = 6
D. doStuffx = 5 main x = 5
E. doStuffx = 5 main x = 6
F. doStuffx = 6 main x = 5
Answer: D
Question 13
Given:
10. package com.sun.scjp;
11. public class Geodetics {
12. public static final double DIAMETER = 12756.32; // kilometers
13. }
Which two correctly access the DIAMETER member of the Geodetics
class? (Choose two.)
A. import com.sun.scjp.Geodetics;
public class TerraCarta {
public double halfway()
{ return Geodetics.DIAMETER/2.0; } }
B. import static com.sun.scjp.Geodetics;
public class TerraCarta {
public double halfway() { return DIAMETER/2.0; } }
C. import static com.sun.scjp.Geodetics. *;
public class TerraCarta {
public double halfway() { return DIAMETER/2.0; } }
D. package com.sun.scjp;
public class TerraCarta {
public double halfway() { return DIAMETER/2.0; } }
Answer: AC
Question 14
Given:
10. class Nav{
11. public enum Direction { NORTH, SOUTH, EAST, WEST }
12. }
13. public class Sprite{
14. // insert code here
15. }
Which code, inserted at line 14, allows the Sprite class to compile?
A. Direction d = NORTH;
B. Nav.Direction d = NORTH;
C. Direction d = Direction.NORTH;
D. Nav.Direction d = Nav.Direction.NORTH;
Answer: D
Question 15
Given:
10. interface Foo { int bar(); }
11. public class Sprite {
12. public int fubar( Foo foo) { return foo.bar(); }
13. public void testFoo() {
14. fubar(
15. // insert code here
16.);
17. }
18. }
Which code, inserted at line 15, allows the class Sprite to compile?
A. Foo { public int bar() { return 1; } }
B. new Foo { public int bar() { return 1; } }
C. newFoo() { public int bar(){return 1; } }
D. new class Foo { public int bar() { return 1; } }
Answer: C
Question 16
Click the Exhibit button.
10. interface Foo {
11. int bar();
12. }
13.
14. public class Beta {
15.
16. class A implements Foo {
17. public int bar() { return 1; }
18. }
19.
20. public int fubar( Foo foo) { return foo.bar(); }
21.
22. public void testFoo() {
23.
24. class A implements Foo {
25. public int bar() { return 2; }
26. }
27.
28. System.out.println( fubar( new A()));
29. }
30.
31. public static void main( String[] argv) {
32. new Beta().testFoo();
33. }
34. }
Which three statements are true? (Choose three.)
A. Compilation fails.
B. The code compiles and the output is 2.
C. If lines 16, 17 and 18 were removed, compilation would fail.
D. If lines 24, 25 and 26 were removed, compilation would fail.
E. If lines 16, 17 and 18 were removed, the code would compile and
the output would be 2.
F. If lines 24, 25 and 26 were removed, the code would compile and
the output would be 1.
Answer: BEF
Question 17
Given:
1. package sun.scjp;
2. public enum Color { RED, GREEN, BLUE }
1. package sun.beta;
2. // insert code here
3. public class Beta {
4. Color g = GREEN;
5. public static void main( String[] argv)
6. { System.out.println( GREEN); }
7. }
The class Beta and the enum Color are in different packages.
Which two code fragments, inserted individually at line 2 of the Beta
declaration, will allow this code to compile? (Choose two.)
A. import sun.scjp.Color.*;
B. import static sun.scjp.Color.*;
C. import sun.scjp.Color; import static sun.scjp.Color.*;
D. import sun.scjp.*; import static sun.scjp.Color.*;
E. import sun.scjp.Color; import static sun.scjp.Color.GREEN;
Answer: CE
Question 18
Given:
1. public interface A {
2. String DEFAULT_GREETING = “Hello World”;
3. public void method1();
4. }
A programmer wants to create an interface called B that has A as its
parent. Which interface declaration is correct?
A. public interface B extends A { }
B. public interface B implements A {}
C. public interface B instanceOf A {}
D. public interface B inheritsFrom A { }
Answer: A
Question 19
Given:
1. class TestA {
2. public void start() { System.out.println(”TestA”); }
3. }
4. public class TestB extends TestA {
5. public void start() { System.out.println(”TestB”); }
6. public static void main(String[] args) {
7. ((TestA)new TestB()).start();
8. }
9. }
What is the result?
A. TestA
B. TestB
C. Compilation fails.
D. An exception is thrown at runtime.
Answer: B
Question 20
Given:
1. interface TestA { String toString(); }
2. public class Test {
3. public static void main(String[] args) {
4. System.out.println(new TestA() {
5. public String toString() { return “test”; }
6. });
7. }
8. }
What is the result?
A. test
B. null
C. An exception is thrown at runtime.
D. Compilation fails because of an error in line 1.
E. Compilation fails because of an error in line 4.
F. Compilation fails because of an error in line 5.
Answer: A
Question 21
Given:
11. public abstract class Shape {
12. int x;
13. int y;
14. public abstract void draw();
15. public void setAnchor(int x, int y) {
16. this.x = x;
17. this.y = y;
18. }
19. }
and a class Circle that extends and fully implements the Shape class.
Which is correct?
A. Shape s = new Shape();
s.setAnchor(10,10);
s.draw();
B. Circle c = new Shape();
c.setAnchor(10,10);
c.draw();
C. Shape s = new Circle();
s.setAnchor(10,10);
s.draw();
D. Shape s = new Circle();
s->setAnchor(10,10);
s->draw();
E. Circle c = new Circle();
c.Shape.setAnchor(10,10);
c.Shape.draw();
Answer: C
Question 22
Given:
10. abstract public class Employee {
11. protected abstract double getSalesAmount();
12. public double getCommision() {
13. return getSalesAmount() * 0.15;
14. }
15. }
16. class Sales extends Employee {
17. // insert method here
18. }
Which two methods, inserted independently at line 17, correctly
complete the Sales class? (Choose two.)
A. double getSalesAmount() { return 1230.45; }
B. public double getSalesAmount() { return 1230.45; }
C. private double getSalesAmount() { return 1230.45; }
D. protected double getSalesAmount() { return 1230.45; }
Answer: BD
Question 23
Given:
10. interface Data { public void load(); }
11. abstract class Info { public abstract void load(); }
Which class correctly uses the Data interface and Info class?
A. public class Employee extends Info implements Data {
public void load() { /*do something*/ }
}
B. public class Employee implements Info extends Data {
public void load() { /*do something*/ }
}
C. public class Employee extends Info implements Data {
public void load() { /*do something */ }
public void Info.load() { /*do something*/ }
}
D. public class Employee implements Info extends Data {
public void Data.load() { /*d something */ }
public void load() { /*do something */ }
}
E. public class Employee implements Info extends Data {
public void load() { /*do something */ }
public void Info.load(){ /*do something*/ }
}
F. public class Employee extends Info implements Data{
public void Data.load() { /*do something*/ }
public void Info.load() { /*do something*/ }
}
Answer: A
Question 24
Given:
11. public abstract class Shape {
12. private int x;
13. private int y;
14. public abstract void draw();
15. public void setAnchor(int x, int y) {
16. this.x = x;
17. this.y = y;
18. }
19. }
Which two classes use the Shape class correctly? (Choose two.)
A. public class Circle implements Shape {
private int radius;
}
B. public abstract class Circle extends Shape {
private int radius;
}
C. public class Circle extends Shape {
private int radius;
public void draw();
}
D. public abstract class Circle implements Shape {
private int radius;
public void draw();
}
E. public class Circle extends Shape {
private int radius;
public void draw() {/* code here */}
}
F. public abstract class Circle implements Shape {
private int radius;
public void draw() { / code here */ }
}
Answer: BE
Question 25
Which two classes correctly implement both the java.lang.Runnable
and the java.lang.Clonable interfaces? (Choose two.)
A. public class Session
implements Runnable, Clonable {
public void run();
public Object clone();
}
B. public class Session
extends Runnable, Clonable {
public void run() { / do something */ }
public Object clone() { / make a copy */ }
}
C. public class Session
implements Runnable, Clonable {
public void run() { / do something */ }
public Object clone() { /* make a copy */ }
}
D. public abstract class Session
implements Runnable, Clonable {
public void run() { / do something */ }
public Object clone() { /*make a copy */ }
}
E. public class Session
implements Runnable, implements Clonable {
public void run() { / do something */ }
public Object clone() { / make a copy */ }
}
Answer: CD
Question26
Click the Exhibit button.
1. public class GoTest {
2. public static void main(String[] args) {
3. Sente a = new Sente(); a.go();
4. Goban b = new Goban(); b.go();
5. Stone c = new Stone(); c.go();
6. }
7. }
8.
9. class Sente implements Go {
10. public void go() { System.out.println(”go in Sente.”); }
11. }
12.
13. class Goban extends Sente {
14. public void go() { System.out.println(”go in Goban”); }
15. }
16.
17. class Stone extends Goban implements Go { }
18.
19. interface Go { public void go(); }
What is the result?
A. go in Goban
go in Sente
go in Sente
B. go in Sente
go in Sente
go in Goban
C. go in Sente
go in Goban
go in Goban
D. go in Goban
go in Goban
go in Sente
E. Compilation fails because of an error in line 17.
Answer: C
Question 27
Given:
11. public static void parse(String str) {
12. try {
13. float f= Float.parseFloat(str);
14. } catch (NumberFormatException nfe) {
15. f= 0;
16. } finally {
17. System.out.println(f);
18. }
19. }
20. public static void main(String[] args) {
21. parse(”invalid”);
22. }
What is the result?
A. 0.0
B. Compilation fails.
C. A ParseException is thrown by the parse method at runtime.
D. A NumberFormatException is thrown by the parse method at
runtime.
Answer: B
Question 28
Click the Exhibit button.
1. public class Test {
2. int x= 12;
3. public void method(int x) {
4. x+=x;
5. System.out.println(x);
6. }
7. }
Given:
34. Test t = new Test();
35. t.method(5);
What is the output from line 5 of the Test class?
A. 5
B. 10
C. 12
D. 17
E. 24
Answer: B
Question 28
Given:
55. int []x= {1, 2,3,4, 5};
56.int y[] =x;
57. System.out.println(y[2]);
Which is true?
A. Line 57 will print the value 2.
B. Line 57 will print the value 3.
C. Compilation will fail because of an error in line 55.
D. Compilation will fail because of an error in line 56.
Answer: B
Question 30
Given:
35. String #name = “Jane Doe”;
36.int$age=24;
37. Double_height = 123.5;
38. double~temp = 37.5;
Which two are true? (Choose two.)
A. Line 35 will not compile.
B. Line 36 will not compile.
C. Line 37 will not compile.
D. Line 38 will not compile.
Answer: AD
Question 31
Which two code fragments correctly create and initialize a static array
of int elements? (Choose two.)
A. static final int[] a = { 100,200 };
B. static final int[] a;
static { a=new int[2]; a[0]=100; a[1]=200; }
C. static final int[] a = new int[2] { 100,200 };
D. static final int[] a;
static void init() { a = new int[3]; a[0]=100; a[1]=200; }
Answer: AB
Question 32
Given:
11. public class Ball {
12. public enum Color { RED, GREEN, BLUE };
13. public void foo() {
14. // insert code here
15. { System.out.println(c); }
16. }
17. }
Which code inserted at line 14 causes the foo method to print RED,
GREEN, and BLUE?
A. for( Color c : Color.values())
B. for( Color c = RED; c <= BLUE; c++)
C. for( Color c; c.hasNext() ; c.next())
D. for( Color c = Color[0]; c <= Color[2]; c++)
E. for( Color c = Color.RED; c <= Color.BLUE; c++)
Answer: A
Question 33
Given:
10. public class Fabric
11. public enum Color {
12. RED(0xff0000), GREEN(0x00ff00), BLUE(0x0000ff);
13. private final int rgb;
14. Color( int rgb) { this.rgb = rgb; }
15. public int getRGB() { return rgb; }
16. };
17. public static void main( String[] argv) {
18. // insert code here
19. }
20. }
Which two code fragments, inserted independently at line 18, allow the
Fabric class to compile? (Choose two.)
A. Color skyColor = BLUE;
B. Color treeColor = Color.GREEN;
C. Color purple = new Color( 0xff00ff);
D. if( RED.getRGB() < BLUE.getRGB() ) {}
E. Color purple = Color.BLUE + Color.RED;
F. if( Color.RED.ordinal() < Color.BLUE.ordinal() ) {}
Answer: BF
Question 34
Given:
11. public enum Title {
12. MR(”Mr.”), MRS(”Mrs.”), MS(”Ms.”);
13. private final String title;
14. private Title(String t) { title = t; }
15. public String format(String last, String first) {
16. return title + “ “ + first + “ “ + last;
17. }
18. }
19. public static void main(String[] args) {
20. System.out.println(Title.MR.format(”Doe”, “John”));
21. }
What is the result?
A. Mr. John Doe
B. An exception is thrown at runtime.
C. Compilation fails because of an error in line 12.
D. Compilation fails because of an error in line 15.
E. Compilation fails because of an error in line 20.
Answer: A
Question 35
Given:
11. public static void main(String[] args) {
12. Object obj =new int[] { 1,2,3 };
13. int[] someArray = (int[])obj;
14. for (int i: someArray) System.out.print(i +“ “)
15. }
‘What is the result?
A. 1 2 3
B. Compilation fails because of an error in line 12.
C. Compilation fails because of an error in line 13.
D. Compilation fails because of an error in line 14.
E. A ClassCastException is thrown at runtime.
Answer: A
Question 36
Given:
10. class Foo {
11. static void alpha() { /* more code here */ }
12. void beta() { /* more code here */ }
13. }
Which two are true? (Choose two.)
A. Foo.beta() is a valid invocation of beta().
B. Foo.alpha() is a valid invocation of alpha().
C. Method beta() can directly call method alpha().
D. Method alpha() can directly call method beta().
Answer: BC
Question 37
A programmer needs to create a logging method that can accept an
arbitrary number of arguments. For example, it may be called in these
ways:
logIt(”log message 1 “);
logIt(”log message2”,”log message3”);
logIt(”log message4”, “log message5”, “log message6);
Which declaration satisfies this requirement?
A. public void logIt(String * msgs)
B. public void logIt(String [] msgs)
C. public void logIt(String... msgs)
D. public void logIt(String msg1, String msg2, String msg3)
Answer: C
Question 38
A programmer is designing a class to encapsulate the information
about an inventory item. A JavaBeans component is needed to
do this. The Inventoryltem class has private instance variables to store
the item information:
10. private int itemId;
11. private String name;
12. private String description;
Which method signature follows the JavaBeans naming standards for
modifying the itemld instance variable?
A. itemID(int itemId)
B. update(int itemId)
C. setItemId(int itemId)
D. mutateItemId(int itemId)
E. updateItemID(int itemId)
Answer: C
Question 39
Click the Exhibit button.
1. public class A {
2.
3. private int counter = 0;
4.
5. public static int getInstanceCount() {
6. return counter;
7. }
8.
9. public A() {
10. counter++;
11. }
12.
13. }
Given this code from Class B:
25.A a1 =new A();
26. A a2 =new A();
27. A a3 =new A();
28. System.out.printIn(A.getInstanceCount() );
What is the result?
A. Compilation of class A fails.
B. Line 28 prints the value 3 to System.out.
C. Line 28 prints the value 1 to System.out.
D. A runtime error occurs when line 25 executes.
E. Compilation fails because of an error on line 28.
Answer: A
Question 40
A JavaBeans component has the following field:
11. private boolean enabled;
Which two pairs of method declarations follow the JavaBeans standard
for accessing this field? (Choose two.)
A. public void setEnabled( boolean enabled)
public boolean getEnabled()
B. public void setEnabled( boolean enabled)
public void isEnabled()
C. public void setEnabled( boolean enabled)
public boolean isEnabled()
D. public boolean setEnabled( boolean enabled)
public boolean getEnabled()
Answer: AC
Question 41
41. Given:
10. class One {
11. public One foo() { return this; }
12. }
13. class Two extends One {
14. public One foo() { return this; }
15. }
16. class Three extends Two {
17. // insert method here
18. }
Which two methods, inserted individually, correctly complete the Three
class? (Choose two.)
A. public void foo() { }
B. public int foo() { return 3; }
C. public Two foo() { return this; }
D. public One foo() { return this; }
E. public Object foo() { return this; }
Answer: CD
Question 42
Given:
10. class One {
11. void foo() {}
12. }
13. class Two extends One {
14. //insert method here
15. }
Which three methods, inserted individually at line 14, will correctly
complete class Two? (Choose three.)
A. int foo() { /* more code here */ }
B. void foo() { /* more code here */ }
C. public void foo() { /* more code here */ }
D. private void foo() { /* more code here */ }
E. protected void foo() { /* more code here */ }
Answer: BCE
Question 43
Click the Exhibit button.
1. public interface A {
2. public void doSomething(String thing);
3. }
1. public class AImpl implements A {
2. public void doSomething(String msg) { }
3. }
1. public class B {
2. public A doit() {
3. // more code here
4. }
5.
6. public String execute() {
7. // more code here
8. }
9. }
1. public class C extends B {
2. public AImpl doit() {
3. // more code here
4. }
5.
6. public Object execute() {
7. // more code here
8. }
9. }
Which statement is true about the classes and interfaces in the
exhibit?
A. Compilation will succeed for all classes and interfaces.
B. Compilation of class C will fail because of an error in line 2.
C. Compilation of class C will fail because of an error in line 6.
D. Compilation of class AImpl will fail because of an error in line 2.
Answer: C
Question 44
Click the Exhibit button.
1. public class A {
2. public String doit(int x, int y) {
3. return “a”;
4. }
5.
6. public String doit(int... vals) {
7. return “b”;
8. }
9. }
Given:
25. A a=new A();
26. System.out.println(a.doit(4, 5));
What is the result?
A. Line 26 prints “a” to System.out.
B. Line 26 prints ‘b” to System.out.
C. An exception is thrown at line 26 at runtime.
D. Compilation of class A will fail due to an error in line 6.
Answer: A
Question 45
Given:
1. public class A {
2. public void doit() {
3. }
4. public String doit() {
5. return “a”;
6. }
7. public double doit(int x) {
8. return 1.0;
9. }
10.}
What is the result?
A. An exception is thrown at runtime.
B. Compilation fails because of an error in line 7.
C. Compilation fails because of an error in line 4.
D. Compilation succeeds and no runtime errors with class A occur.
Answer: C
Question 46
46. Given:
10. class Line {
11. public static class Point { }
12. }
13.
14. class Triangle {
15. // insert code here
16. }
Which code, inserted at line 15, creates an instance of the Point class
defined in Line?
A. Point p = new Point();
B. Line.Point p = new Line.Point();
C. The Point class cannot be instatiated at line 15.
D. Line 1 = new Line() ; 1.Point p = new 1.Point();
Answer: B
Question 47
Given:
10. class Line {
11. public class Point { public int x,y; }
12. public Point getPoint() { return new Point(); }
13. }
14. class Triangle {
15. public Triangle() {
16. // insert code here
17. }
18. }
Which code, inserted at line 16, correctly retrieves a local instance of a
Point object?
A. Point p = Line.getPoint();
B. Line.Point p = Line.getPoint();
C. Point p = (new Line()).getPoint();
D. Line.Point p = (new Line()).getPoint();
Answer: D
Question 48
Given:
10. class One {
11. public One() { System.out.print(1); }
12. }
13. class Two extends One {
14. public Two() { System.out.print(2); }
15. }
16. class Three extends Two {
17. public Three() { System.out.print(3); }
18. }
19. public class Numbers{
20. public static void main( String[] argv) { new Three(); }
21. }
What is the result when this code is executed?
A. 1
B. 3
C. 123
D. 321
E. The code rims with no output.
Answer: C
Question 49
Click the Exhibit button.
11. class Person {
12. String name = “No name’;
13. public Person(String nm) { name = nm; }
14. }
15.
16. class Employee extends Person {
17. String emplD = “0000”;
18. public Employee(String id) { empID = id; }
19. }
20.
21. public class EmployeeTest {
22. public static void main(String[] args) {
23. Employee e = new Employee(”4321”);
24. System.out.println(e.empID);
25. }
26. }
What is the result?
A. 4321
B. 0000
C. An exception is thrown at runtime.
D. Compilation fails because of an error in line 18.
Answer: D
Question 50
Given:
1. public class Plant {
2. private String name;
3. public Plant(String name) { this.name = name; }
4. public String getName() { return name; }
5. }
1. public class Tree extends Plant {
2. public void growFruit() { }
3. public void dropLeaves() { }
4. }
Which is true?
A. The code will compile without changes.
B. The code will compile if public Tree() { Plant(); } is added to the
Tree class.
C. The code will compile if public Plant() { Tree(); } is added to the
Plant class.
D. The code will compile if public Plant() { this(”fern”); } is added to
the Plant class.
E. The code will compile if public Plant() { Plant(”fern”); } is added to
the Plant class.
Answer: D
Question 51
Click the Exhibit button.
11. public class Bootchy {
12. int bootch;
13. String snootch;
14.
15. public Bootchy() {
16. this(”snootchy”);
17. System.out.print(”first “);
18. }
19.
20. public Bootchy(String snootch) {
21. this(420, “snootchy”);
22. System.out.print(”second “);
23. }
24.
25. public Bootchy(int bootch, String snootch) {
26. this.bootch = bootch;
27. this.snootch = snootch;
28. System.out.print(”third “);
29. }
30.
31. public static void main(String[] args) {
32. Bootchy b = new Bootchy();
33. System.out.print(b.snootch +“ “ + b.bootch);
34. }
35. }
What is the result?
A. snootchy 420 third second first
B. snootchy 420 first second third
C. first second third snootchy 420
D. third second first siiootchy 420
E. third first second snootchy 420
F. first second first third snootchy 420
Answer: D
Question 52
Given:
11. public class Test {
12. public enum Dogs {collie, harrier, shepherd};
13. public static void main(String [] args) {
14. Dogs myDog = Dogs.shepherd;
15. switch (myDog) {
16. case collie:
17. System.out.print(”collie “);
18. case default:
19. System.out.print(”retriever “);
20. case harrier:
21. System.out.print(”harrier “);
22. }
23. }
24. }
‘What is the result?
A. harrier
B. shepherd
C. retriever
D. Compilation fails.
E. retriever harrier
F. An exception is thrown at runtime.
Answer: D
Question 53
Given:
12. public class Test {
13. public enum Dogs {collie, harrier};
14. public static void main(String [] args) {
15. Dogs myDog = Dogs.collie;
16. switch (myDog) {
17. case collie:
18. System.out.print(”collie “);
19. case harrier:
20. System.out.print(”harrier “);
21. }
22. }
23. }
What is the result?
A. collie
B. harrier
C. Compilation fails.
D. collie harrier
E. An exception is thrown at runtime.
Answer: D
Question 54
Given:
11. public void testIfA() {
12. if(testIfB(”True”)) {
13. System.out.println(”True”);
14. } else {
15. System.out.println(”Not true”);
16. }
17. }
18. public Boolean testIfB(String str) {
19. return Boolean.valueOf(str);
20. }
What is the result when method testIfA is invoked?
A. True
B. Not true
C. An exception is thrown at runtime.
D. Compilation fails because of an error at line 12.
E. Compilation fails because of an error at line 19.
Answer: A
Question 55
Given:
11. public static void main(String[] args) {
12. Integer i = uew Integer(1) + new Integer(2);
13. switch(i) {
14. case 3: System.out.println(”three”); break;
15. default: System.out.println(”other”); break;
16. }
17. }
‘What is the result?
A. three
B. other
C. An exception is thrown at runtime.
D. Compilation fails because of an error on line 12.
E. Compilation fails because of an error on line 13.
F. Compilation fails because of an error on line 15.
Answer: A
Question 56
Given:
11. public static void main(String[] args) {
12. String str = “null’;
13. if (str == null) {
14. System.out.println(”null”);
15. } else (str.length() == 0) {
16. System.out.println(”zero”);
17. } else {
18. System.out.println(”some”);
19. }
20. }
‘What is the result?
A. null
B. zero
C. some
D. Compilation fails.
E. An exception is thrown at runtime.
Answer: D
Question 57
Given:
11. Float pi = new Float(3.14f);
12.if(pi>3) {
13. System.out.print(”pi is bigger than 3. “);
14. }
15. else {
16. System.out.print(”pi is not bigger than 3. “);
17. }
18. finally {
19. System.out.println(”Have a nice day.”);
20. }
‘What is the result?
A. Compilation fails.
B. pi is bigger than 3.
C. An exception occurs at runtime.
D. pi is bigger than 3. Have a nice day.
E. pi is not bigger than 3. Have a nice day.
Answer: A
Question 58
Given:
10.int x=0;
11.int y 10;
12. do {
l3. y--;
14. ++x;
15. } while (x < 5);
16. System.out.print(x + “,“ + y);
What is the result?
A. 5,6
B. 5,5
C. 6,5
D. 6,6
Answer: B
Question 59
Given:
25.intx=12;
26. while (x < 10) {
27. x--;
28. }
29. System.out.print(x);
What is the result?
A. 0
B. 10
C. 12
D. Line 29 will never be reached.
Answer: C
Question 60
Given:
35. int x= 10;
36. do {
37. x--;
38. } while(x< 10);
How many times will line 37 be executed?
A. ten times
B. zero times
C. one to me times
D. more than ten times
Answer: D
Question 61
Give:
11. public static Iterator reverse(List list) {
12. Collections.reverse(list);
13. return list.iterator();
14. }
15. public static void main(String[] args) {
16. List list = new ArrayList();
17. list.add(” 1”); list.add(”2”); list.add(”3”);
18. for (Object obj: reverse(list))
19. System.out.print(obj + “,”);
20. }
‘What is the result?
A. 3,2, 1,
B. 1, 2, 3,
C. Compilation fails.
D. The code runs with no output.
E. An exception is thrown at runtime.
Answer: C
Question 62
Given:
11. public static Collection get() {
12. Collection sorted = new LinkedList();
13. sorted.add(’B”); sorted.add(”C”); sorted.add(”A”);
14. return sorted;
15. }
16. public static void main(String[] args) {
17. for (Object obj: get()) {
18. System.out.print(obj + “, “);
19. }
20. }
What is the result?
A. A, B, C,
B. B, C, A,
C. Compilation fails.
D. The code runs with no output.
E. An exception is thrown at runtime.
Answer: B
Question 63
Given:
11. public static void main(String[] args) {
12. for (int i=0;i<= 10;i++){
13. if( i>6) break;
14. }
15. System.out.println(i);
16. }
What is the result?
A. 6
B. 7
C. 10
D. 11
E. Compilation fails.
F. An exception is thrown at runtime.
Answer: E
Question 64
Given:
8. public class test {
9. public static void main(String [] a) {
10. assert a.length == 1;
11. }
12. }
Which two will produce an AssertionError? (Choose two.)
A. java test
B. java -ea test
C. java test file1
D. java -ea test file1
E. java -ea test file1 file2
F. java -ea:test test file1
Answer: BE
Question 65
Given:
12. public class AssertStuff {
13.
14. public static void main(String [] args) {
15. int x= 5;
16. int y= 7;
17.
18. assert (x> y): “stuff”;
19. System.out.println(”passed”);
20. }
21. }
And these command line invocations:
java AssertStuff
java -ea AssertStuff
What is the result?
A. passed
stuff
B. stuff
passed
C. passed
An AssertionError is thrown with the word “stuff” added to the stack
trace.
D. passed
An AssertionError is thrown without the word “stuff” added to the
stack trace.
E. passed
An AssertionException is thrown with the word “stuff” added to the
stack trace.
F. passed
An AssertionException is thrown without the word “stuff” added to the
stack trace.
Answer: C
Question 66
Click the Exhibit button.
1. public class Test {
2.
3. public static void main(String [] args) {
4. boolean assert = true;
5. if(assert) {
6. System.out.println(”assert is true”);
7. }
8. }
9.
10. }
Given:
javac -source 1.3 Test.java
What is the result?
A. Compilation fails.
B. Compilation succeeds with errors.
C. Compilation succeeds with warnings.
D. Compilation succeeds without warnings or errors.
Answer: C
Question 67
Given:
23.int z=5;
24.
25. public void stuff1(int x) {
26. assert (x> 0);
27. switch(x) {
28. case 2: x= 3;
29. default: assert false; } }
30.
31. private void stuff2(int y) { assert (y < 0); }
32.
33. private void stuff3() { assert (stuff4O); }
34.
35. private boolean stuff4() { z = 6; return false; }
Which is true?
A. All of the assert statements are used appropriately.
B. Only the assert statement on line 31 is used appropriately.
C. The assert statements on lines 29 and 31 are used appropriately.
D. The assert statements on lines 26 and 29 are used appropriately.
E. The assert statements on lines 29 and 33 are used appropriately.
F. The assert statements on lines 29, 31, and 33 are used
appropriately.
G. The assert statements on lines 26, 29, and 31 are used
appropriately.
Answer: C
Question 68
Click the Exhibit button.
SomeException:
1. public class SomeException {
2. }
Class A:
1. public class A {
2. public void doSomething() { }
3. }
Class B:
1. public class B extends A {
2. public void doSomething() throws SomeException { }
3. }
Which is true about the two classes?
A. Compilation of both classes will fail.
B. Compilation of both classes will succeed.
C. Compilation of class A will fail. Compilation of class B will succeed.
D. Compilation of class B will fail. Compilation of class A will succeed.
Answer: D
Question 69
Click the Exhibit button.
Class TestException
1. public class TestException extends Exception {
2. }
Class A:
1. public class A {
2.
3. public String sayHello(String name) throws TestException {
4.
5. if(name == null) {
6. throw new TestException();
7. }
8.
9. return “Hello “+ name;
10. }
11.
12. }
A programmer wants to use this code in an application:
45. A a=new A();
46. System.out.println(a.sayHello(”John”));
Which two are true? (Choose two.)
A. Class A will not compile.
B. Line 46 can throw the unchecked exception TestException.
C. Line 45 can throw the unchecked exception TestException.
D. Line 46 will compile if the enclosing method throws a TestException.
E. Line 46 will compile if enclosed in a try block, where TestException
is caught.
Answer: DE
Question 70
Given:
33. try {
34. // some code here
35. } catch (NullPointerException e1) {
36. System.out.print(”a”);
37. } catch (RuntimeException e2) {
38. System.out.print(”b”);
39. } finally {
40. System.out.print(”c”);
41. }
What is the result if a NullPointerException occurs on line 34?
A. c
B. a
C. ab
D. ac
E. bc
F. abc
Answer: D
Question 71
Given:
11.classA {
12. public void process() { System.out.print(”A,”); } }
13. class B extends A {
14. public void process() throws IOException {
15. super.process();
16. System.out.print(”B,”);
17. throw new IOException();
18. } }
19. public static void main(String[] args) {
20. try { new B().process(); }
21. catch (IOException e) { System.out.println(”Exception”); } }
What is the result?
A. Exception
B. A,B,Exception
C. Compilation fails because of an error in line 20.
D. Compilation fails because of an error in line 14.
E. A NullPointerException is thrown at runtime.
Answer: D
Question 72
Given:
11.classA {
12. public void process() { System.out.print(”A “); } }
13. class B extends A {
14. public void process() throws RuntimeException {
15. super.process();
16. if (true) throw new RuntimeException();
17. System.out.print(“B”); }}
18. public static void main(String[] args) {
19. try { ((A)new B()).process(); }
20. catch (Exception e) { System.out.print(”Exception “); }
21. }
What is the result?
A. Exception
B. A Exception
C. A Exception B
D. A B Exception
E. Compilation fails because of an error in line 14.
F. Compilation fails because of an error in line 19.
Answer: B
Question 73
Given:
11. static classA {
12. void process() throws Exception { throw new Exception(); }
13. }
14. static class B extends A {
15. void process() { System.out.println(”B “); }
16. }
17. public static void main(String[] args) {
18.A a=new B();
19. a.process();
20.}
What is the result?
A. B
B. The code runs with no output.
C. An exception is thrown at runtime.
D. Compilation fails because of an error in line 15.
E. Compilation fails because of an error in line 18.
F. Compilation fails because of an error in line 19.
Answer: F
Question 74
Given:
11. static class A {
12. void process() throws Exception { throw new Exception(); }
13. }
14. static class B extends A {
15. void process() { System.out.println(”B”); }
16. }
17. public static void main(String[] args) {
18. new B().process();
19. }
What is the result?
A. B
B. The code runs with no output.
C. Compilation fails because of an error in line 12.
D. Compilation fails because of an error in line 15.
E. Compilation fails because of an error in line 18.
Answer: A
Question 75
Given:
84. try {
85. ResourceConnection con = resourceFactory.getConnection();
86. Results r = con.query(”GET INFO FROM CUSTOMER”);
87. info = r.getData();
88. con.close();
89. } catch (ResourceException re) {
90. errorLog.write(re.getMessage());
91. }
92. return info;
Which is true if a ResourceException is thrown on line 86?
A. Line 92 will not execute.
B. The connection will not be retrieved in line 85.
C. The resource connection will not be closed on line 88.
D. The enclosing method will throw an exception to its caller.
Answer: C
Question 76
Click the Exhibit button.
1. public class A {
2. public void method1() {
3. B b=new B();
4. b.method2();
5. // more code here
6. }
7. }
1. public class B {
2. public void method2() {
3.C c=new C();
4. c.method3();
5. // more code here
6. }
7. }
1. public class C {
2. public void method3() {
3. // more code here
4. }
5. }
Given:
25. try {
26. A a=new A();
27. a.method1();
28. } catch (Exception e) {
29. System.out.print(”an error occurred”);
30. }
Which two are true if a NullPointerException is thrown on line 3 of
class C? (Choose two.)
A. The application will crash.
B. The code on line 29 will be executed.
C. The code on line 5 of class A will execute.
D. The code on line 5 of class B will execute.
E. The exception will be propagated back to line 27.
Answer: BE
Question 77
Click the Exhibit button.
1. public class A {
2. public void method1() {
3. try {
4. B b=new B();
5. b.method2();
6. // more code here
7. } catch (TestException te) {
8. throw new RuntimeException(te);
9. }
6. }
7. }
1. public class B {
2. public void method2() throws TestException {
3. // more code here
4. }
5. }
1. public class TestException extends Exception {
2. }
Given:
31. public void method() {
32. A a=new A();
33. a.method1();
34. }
Which is true if a TestException is thrown on line 3 of class B?
A. Line 33 must be called within a try block.
B. The exception thrown by method1 in class A is not required to be
caught.
C. The method declared on line 31 must be declared to throw a
RuntimeException.
D. On line 5 of class A, the call to method2 of class B does not need to
be placed in a try/catch block.
Answer: B
Question 78
Given:
11. public static void main(String[] args) {
12. try {
13. args=null;
14. args[0] = “test”;
15. System.out.println(args[0]);
16. } catch (Exception ex) {
17. System.out.println(”Exception”);
18. } catch (NullPointerException npe) {
19. System.out.println(”NullPointerException”);
20. }
21. }
What is the result?
A. test
B. Exception
C. Compilation fails.
D. NullPointerException
Answer: C
Question 79
Given:
11. static void test() throws Error {
12. if (true) throw new AssertionError();
13. System.out.print(”test “);
14. }
15. public static void main(String[] args) {
16. try { test(); }
17. catch (Exception ex) { System.out.print(”exception “); }
18. System.out.print(”elld “);
19. }
What is the result?
A. end
B. Compilation fails.
C. exception end
D. exception test end
E. A Throwable is thrown by main.
F. An Exception is thrown by main.
Answer: E
Question 80
Given:
11. static void test() {
12. try {
13. String x=null;
14. System.out.print(x.toString() +“ “);
15. }
16. finally { System.out.print(“finally “); }
17. }
18. public static void main(String[] args) {
19. try { test(); }
20. catch (Exception ex) { System.out.print(”exception “); }
21. }
What is the result?
A. null
B. finally
C. null finally
D. Compilation fails.
E. finally exception
Answer: E
Question 81
Given:
11. static void test() throws RuntimeException {
12. try {
13. System.out.print(”test “);
14. throw new RuntimeException();
15. }
16. catch (Exception ex) { System.out.print(”exception “); }
17. }
18. public static void main(String[] args) {
19. try { test(); }
20. catch (RuntimeException ex) { System.out.print(”runtime “); }
21. System.out.print(”end “);
22. }
What is the result?
A. test end
B. Compilation fails.
C. test runtime end
D. test exception end
E. A Throwable is thrown by main at runtime.
Answer: D
Question 82
Given a method that must ensue that its parameter is not null:
11. public void someMethod(Object value) {
12. // check for null value
....
20. System.out.println(value.getClass());
21. }
What, inserted at line 12, is the appropriate way to handle a null
value?
A. assert value == null;
B. assert value !null, “value is null”;
C. if (value == null) {
throw new AssertionException(”value is null”);
D. if (value == null) {
throw new IllegalArgumentException(”value is null”);
Answer: D
Question 83
Click the Exhibit button.
10. public class ClassA {
11. public void methodA() {
12. ClassB classB = new ClassB();
13. classB.getValue();
14. }
15. }
And:
20. class ClassB {
21. public ClassC classC;
22.
23. public String getValue() {
24. return classC.getValue();
25. }
26. }
And:
30. class ClassC {
31. public String value;
32.
33. public String getValue() {
34. value = “ClassB”;
35. return value;
36. }
37. }
Given:
ClassA a = new ClassA();
a.methodA();
What is the result?
A. Compilation fails.
B. ClassC is displayed.
C. The code runs with no output.
D. An exception is thrown at runtime.
Answer: D
Question 84
Given:
10. public class Foo {
11. static int[] a;
12. static { a[0]=2; }
13. public static void main( String[] args) {}
14. }
Which exception or error will be thrown when a programmer attempts
to run this code?
A. java.lang. StackOverflowError
B. java.lang.IllegalStateException
C. java.lang.ExceptionlnlnitializerError
D. java.lang.ArraylndexOutOfBoundsException
Answer: C
Question 85
Given:
10. public class ClassA {
11. public void count(int i) {
12. count(++i);
13. }
14. }
And:
20. ClassA a = new ClassA();
21. a.count(3);
Which exception or error should be thrown by the virtual machine?
A. StackOverflowError
B. NullPointerException
C. NumberFormatException
D. IllegalArgumentException
E. ExceptionlnlnitializerError
Answer: A
Question 86
Given:
1. public class Boxer1 {
2. Integer i;
3. int x;
4. public Boxer1(int y) {
5. x=i+y;
6. System.out.println(x);
7. }
8. public static void main(String[] args) {
9. new Boxer1(new Integer(4));
10. }
11. }
What is the result?
A. The value “4” is printed at the command line.
B. Compilation fails because of an error in line 5.
C. Compilation fails because of an error in line 9.
D. A NullPointerException occurs at runtime.
E. A NumberFormatException occurs at runtime.
F. An IllegalStateException occurs at runtime.
Answer: D
Question 87
Given:
1. public class TestString 1 {
2. public static void main(String[] args) {
3. String str = “420”;
4. str += 42;
5. System.out.print(str);
6. }
7. }
What is the output?
A. 42
B. 420
C. 462
D. 42042
E. Compilation fails.
F. An exception is thrown at runtime.
Answer: D
Question 88
Given:
11. class Converter {
12. public static void main(String[] args) {
13. Integer i = args[0];
14. int j = 12;
15. System.out.println(”It is “ + (j==i) + “that j==i.”);
16. }
17. }
What is the result when the programmer attempts to compile the code
and run it with the command java Converter 12?
A. It is true that j==i.
B. It is false that j==i.
C. An exception is thrown at runtime.
D. Compilation fails because of an error in line 13.
Answer: D
Question 89
Given this method in a class:
21. public String toString() {
22. StringBuffer buffer = new StringBuffer();
23. buffer.append(’<’);
24. buffer.append(this.name);
25. buffer.append(’>’);
26. return buffer.toString();
27. }
Which is true?
A. This code is NOT thread-safe.
B. The programmer can replace StringBuffer with StringBuilder with no
other changes.
C. This code will perform well and converting the code to use
StringBuilder will not enhance the performance.
D. This code will perform poorly. For better performance, the code
should be rewritten: return “<“+ this.name + “>”;
Answer: B
Question 90
Given:
1. public class MyLogger {
2. private StringBuilder logger = new StringBuuilder();
3. public void log(String message, String user) {
4. logger.append(message);
5. logger.append(user);
6. }
7. }
The programmer must guarantee that a single MyLogger object works
properly for a multi-threaded system. How must this code be changed
to be thread-safe?
A. synchronize the log method
B. replace StringBuilder with StringBuffer
C. No change is necessary, the current MyLogger code is already
thread-safe.
D. replace StringBuilder with just a String object and use the string
concatenation (+=) within the log method
Answer: A
Question 91
Given:
11. public String makinStrings() {
12. String s = “Fred”;
13. s = s + “47”;
14. s = s.substring(2, 5);
15. s = s.toUpperCase();
16. return s.toString();
17. }
How many String objects will be created when this method is invoked?
A. 1
B. 2
C. 3
D. 4
E. 5
F. 6
Answer: C
Question 92
Given:
1. public class TestString3 {
2. public static void main(String[] args) {
3. // insert code here
5. System.out.println(s);
6. }
7. }
Which two code fragments, inserted independently at line 3, generate
the output 4247? (Choose two.)
A. String s = “123456789”;
s = (s-”123”).replace(1,3,”24”) - “89”;
B. StringBuffer s = new StringBuffer(”123456789”);
s.delete(0,3).replace( 1,3, “24”).delete(4,6);
C. StringBuffer s = new StringBuffer(”123456789”);
s.substring(3,6).delete( 1 ,3).insert( 1, “24”);
D. StringBuilder s = new StringBuilder(”123456789”);
s.substring(3,6).delete( 1 ,2).insert( 1, “24”);
E. StringBuilder s = new StringBuilder(”123456789”);
s.delete(0,3).delete( 1 ,3).delete(2,5).insert( 1, “24”);
Answer: BE
Question 93
Given:
11. public class Yikes {
12.
13. public static void go(Long n) {System.out.println(”Long “);}
14. public static void go(Short n) {System.out.println(”Short “);}
15. public static void go(int n) {System.out.println(”int “);}
16. public static void main(String [] args) {
17. short y= 6;
18. long z= 7;
19. go(y);
20. go(z);
21. }
22. }
What is the result?
A. int Long
B. Short Long
C. Compilation fails.
D. An exception is thrown at runtime.
Answer: A
Question 94
Given:
12. public class Wow {
13. public static void go(short n) {System.out.println(”short”); }
14. public static void go(Short n) {System.out.println(”SHORT”);}
15. public static void go(Long n) {System.out.println(” LONG”); }
16. public static void main(String [] args) {
17. Short y= 6;
18.int z=7;
19. go(y);
20. go(z);
21. }
22. }
What is the result?
A. short LONG
B. SHORT LONG
C. Compilation fails.
D. An exception is thrown at runtime.
Answer: C
Question 95
Given:
10. class MakeFile {
11. public static void main(String[] args) {
12. try {
13. File directory = new File(”d”);
14. File file = new File(directory,”f”);
15. if(!file.exists()) {
16. file.createNewFile();
17. }
18. } catch (IOException e) {
19. e.printStackTrace
20. }
21. }
22. }
The current directory does NOT contain a directory named “d.”
Which three are true? (Choose three.)
A. Line 16 is never executed.
B. An exception is thrown at runtime.
C. Line 13 creates a File object named “d.”
D. Line 14 creates a File object named “f.’
E. Line 13 creates a directory named “d” in the file system.
F. Line 16 creates a directory named “d” and a file ‘f’ within it in the
file system.
G. Line 14 creates a file named ‘f’ inside of the directory named “d” in
the file system.
Answer: BCD
Question 96
When comparing java.io.BufferedWriter to java.io.FileWriter, which
capability exists as a method in only one of the two?
A. closing the stream
B. flushing the stream
C. writing to the stream
D. marking a location in the stream
E. writing a line separator to the stream
Answer: E
Question 97
Given:
12. import java.io.*;
13. public class Forest implements Serializable {
14. private Tree tree = new Tree();
15. public static void main(String [] args) {
16. Forest f= new Forest();
17. try {
18. FileOutputStream fs = new FileOutputStream(”Forest.ser”);
19. ObjectOutputStream os = new ObjectOutputStream(fs);
20. os.writeObject(f); os.close();
21. } catch (Exception ex) { ex.printStackTrace(); }
22. } }
23.
24. class Tree { }
What is the result?
A. Compilation fails.
B. An exception is thrown at runtime.
C. An instance of Forest is serialized.
D. A instance of Forest and an instance of Tree are both serialized.
Answer: B
Question 98
Click the Exhibit button.
1. import java.io.*;
2. public class Foo implements Serializable {
3. public int x, y;
4. public Foo( int x, int y) { this.x = x; this.y = y; }
5.
6. private void writeObject( ObjectOutputStream s)
7. throws IOException {
8. s.writeInt(x); s.writeInt(y)
9. }
10.
11. private void readObject( ObjectInputStream s)
12. throws IOException, ClassNotFoundException {
13.
14. // insert code here
15.
16. }
17. }
Which code, inserted at line 14, will allow this class to correctly
serialize and deserialize?
A. s.defaultReadObject();
B. this = s.defaultReadObject();
C. y = s.readInt(); x = s.readInt();
D. x = s.readInt(); y = s.readInt();
Answer: D
Question 99
Which three concerning the use of the java.io.Serializable interface are
true? (Choose three.)
A. Objects from classes that use aggregation cannot be serialized.
B. Art object serialized on one JVM can be successfully deserialized on
a different JVM.
C. The values in fields with the volatile modifier will NOT survive
serialization and deserialization.
D. The values in fields with the transient modifier will NOT survive
serialization and deserialization.
E. It is legal to serialize an object of a type that has a supertype that
does NOT implement java.io.Serializable.
Answer: BDE
Question 100
Assuming that the serializeBanana() and the deserializeBanana()
methods will correctly use Java serialization and given:
13. import java.io.*;
14. class Food implemertts Serializable {int good = 3;}
15. class Fruit externds Food {int juice = 5;}
16. public class Banana extends Fruit {
17. int yellow = 4;
18. public static void main(String [] args) {
19. Banana b = new Banana(); Banana b2 = new Banana();
20. b.serializeBanana(b); // assume correct serialization
21. b2 = b.deserializeBanana(); // assume correct
22. System.out.println(”restore “+b2.yellow+ b2.juice+b2.good);
24. }
25. // more Banana methods go here
50. }
‘What is the result?
A. restore 400
B. restore 403
C. restore 453
D. Compilation fails.
E. An exception is thrown at runtime.
Answer: C
Question 101
Assuming that the serializeBanana2() and the deserializeBanana2()
methods will correctly use Java serialization and given:
13. import java.io.*;
14. class Food {Food() { System.out.print(”1”); } }
15. class Fruit extends Food implements Serializable {
16. Fruit() { System.out.print(”2”); } }
17. public class Banana2 extends Fruit { int size = 42;
18. public static void main(String [] args) {
19. Banana2 b = new Banana2();
20. b.serializeBanana2(b); // assume correct serialization
21. b = b.deserializeBanana2(b); // assume correct
22. System.out.println(” restored “+ b.size + “ “); }
23. // more Banana2 methods
24. }
What is the result?
A. Compilation fails.
B. 1 restored 42
C. 12 restored 42
D. 121 restored 42
E. 1212 restored 42
F. An exception is thrown at runtime.
Answer: D
Question 102
Given:
10. public class Foo implements java.io.Serializable {
11. private int x;
12. public int getX() { return x; }
12.publicFoo(int x){this.x=x; }
13. private void writeObject( ObjectOutputStream s)
14. throws IOException {
15. // insert code here
16. }
17. }
Which code fragment, inserted at line 15, will allow Foo objects to be
correctly serialized and deserialized?
A. s.writeInt(x);
B. s.serialize(x);
C. s.writeObject(x);
D. s.defaultWriteObject();
Answer: D
Question 103
Given:
12. NumberFormat nf= NumberFormat.getInstance();
13. nf.setMaximumFractionDigits(4);
14. nf.setMinimumFractionDigits(2);
15. String a = nf.format(3.1415926);
16. String b = nf.format(2);
Which two are true about the result if the default locale is Locale.US?
(Choose two.)
A. The value of b is 2.
B. The value of a is 3.14.
C. The value of b is 2.00.
D. The value of a is 3.141.
E. The value of a is 3.1415.
F. The value of a is 3.1416.
G. The value of b is 2.0000.
Answer: CF
Question 104
Given:
11. double input = 314159.26;
12. NumberFormat nf= NumberFormat.getInstance(Locale.ITALIAN);
13. String b;
14. //insert code here
Which code, inserted at line 14, sets the value of b to 3 14.159,26?
A. b = nf.parse( input);
B. b = nf.format( input);
C. b = nf.equals( input);
D. b = nf.parseObject( input);
Answer: B
Question 105
Given:
14. DateFormat df;
15. Date date = new Date();
16. //insert code here
17. String s = df.format( date);
Which two, inserted independently at line 16, allow the code to
compile? (Choose two.)
A. df= new DateFormat();
B. df= Date.getFormatter();
C. df= date.getFormatter();
D. df= date.getDateFormatter();
E. df= Date.getDateFormatter();
F. df= DateFormat.getInstance();
G. df = DateFormat.getDateInstance();
Answer: FG
Question 106
Given:
12. Date date = new Date();
13. df.setLocale(Locale.ITALY);
14. String s = df.format(date);
The variable df is an object of type DateFormat that has been
initialized in line 11. What is the result if this code is run on December
14, 2000?
A. The value of s is 14-dic-2004.
B. The value of s is Dec 14, 2000.
C. An exception is thrown at runtime.
D. Compilation fails because of an error in line 13.
Answer: D
Question 107
Given:
33. Date d = new Date(0);
34. String ds = “December 15, 2004”;
35. // insert code here
36. try {
37. d = df.parse(ds);
38. }
39. catch(ParseException e) {
40. System.out.println(”Unable to parse “+ ds);
41. }
42. // insert code here too
Which will create the appropriate DateFormat object and add a day to
the Date object?
A. 35. DateFormat df= DateFormat.getDateFormat();
42. d.setTime( (60 * 60 * 24) + d.getTime());
B. 35. DateFormat df= DateFormat.getDateJnstance();
42. d.setTime( (1000 * 60 * 60 * 24) + d.getTime());
C. 35. DateFormat df= DateFormat.getDateFormat();
42. d.setLocalTime( (1000*60*60*24) + d.getLocalTime());
D. 35. DateFormat df= DateFormat.getDateJnstance();
42. d.setLocalTime( (60 * 60 * 24) + d.getLocalTime());
Answer: B
Question 108
Given a valid DateFormat object named df, and
16. Date d = new Date(0L);
17. String ds = “December 15, 2004”;
18. // insert code here
What updates d’s value with the date represented by ds?
A. 18. d = df.parse(ds);
B. 18. d = df.getDate(ds);
C. 18. try {
19. d = df.parse(ds);
20. } catch(ParseException e) { };
D. 18. try {
19. d = df.getDate(ds);
20. } catch(ParseException e) { };
Answer: C
Question 109
Given:
11. String test = “This is a test”;
12. String[] tokens = test.split(”\s”);
13. System.out.println(tokens.length);
What is the result?
A. 0
B. 1
C. 4
D. Compilation fails.
E. An exception is thrown at runtime.
Answer: D
Question 110
Given:
11. String test= “a1b2c3”;
12. String[] tokens = test.split(”\\d”);
13. for(String s: tokens) System.out.print(s +“ “);
What is the result?
A. a b c
B. 1 2 3
C. a1b2c3
D. a1 b2 c3
E. Compilation fails.
F. The code runs with no output.
G. An exception is thrown at runtime.
Answer: A
Question 111
Given:
11. String test = “Test A. Test B. Test C.”;
12. // insert code here
13. String[] result = test.split(regex);
Which regular expression inserted at line 12 will correctly split test into
“Test A,” “Test B,” and “Test C”?
A. String regex = “”;
B. String regex = “ “;
C. String regex = “.*“.
D. String regex = “\\s”
E. String regex = “\\.\\s*”;
F. String regex = “\\w[ \.] +“;
Answer: E
Question 112
Given:
12. System.out.format(”Pi is approximately %d.”, Math.PI);
What is the result?
A. Compilation fails.
B. Pi is approximately 3.
C. Pi is approximately 3.141593.
D. An exception is thrown at runtime.
Answer: D
Question 113
Given:
12. String csv = “Sue,5,true,3”;
13. Scanner scanner = new Scanner( csv);
14. scanner.useDelimiter(”,”);
15. int age = scanner.nextInt();
What is the result?
A. Compilation fails.
B. After line 15, the value of age is 5.
C. After line 15, the value of age is 3.
D. An exception is thrown at runtime.
Answer: D
Question 114
Which two code fragments will execute the method doStuff() in a
separate thread? (Choose two.)
A. new Thread() {
public void run() { doStuff(); }
}
B. new Thread() {
public void start() { doStuff(); }
}
C. new Thread() {
public void start() { doStuff(); }
} .run();
D. new Thread() {
public void run() { doStuff(); }
} .start();
E. new Thread(new Runnable() {
public void run() { doStuff(); }
} ).run();
F. new Thread(new Runnable() {
public void run() { doStuff(); }
}).start();
Answer: DF
Question 115
Given:
1. public class Threads3 implements Runnable {
2. public void run() {
3. System.out.print(”running”);
4. }
5. public static void main(String[] args) {
6. Thread t = new Thread(new Threads3());
7. t.run();
8. t.run();
9. t.start();
10. }
11. }
What is the result?
A. Compilation fails.
B. An exception is thrown at runtime.
C. The code executes and prints “running”.
D. The code executes and prints “runningrunning”.
E. The code executes and prints “runningrunningrunning”.
Answer: E
Question 116
Given:
1. public class Threads4 {
2. public static void main (String[] args) {
3. new Threads4().go();
4. }
5. public void go() {
6. Runnable r = new Runnable() {
7. public void run() {
8. System.out.print(”foo”);
9. }
10. };
11. Thread t = new Thread(r);
12. t.start();
13. t.start();
14. }
15. }
What is the result?
A. Compilation fails.
B. An exception is thrown at runtime.
C. The code executes normally and prints ‘foo”.
D. The code executes normally, but nothing is printed.
Answer: B
Question 117
Given:
1. public class Threads5 {
2. public static void main (String[] args) {
3. new Thread(new Runnable() {
4. public void run() {
5. System.out.print(”bar”);
6. }}).start();
7. }
8. }
What is the result?
A. Compilation fails.
B. An exception is thrown at runtime.
C. The code executes normally and prints “bar”.
D. The code executes normally, but nothing prints.
Answer: C
Question 118
Given:
11. Runnable r = new Runnable() {
12. public void run() {
13. System.out.print(”Cat”);
14. }
15. };
16. Threadt=new Thread(r) {
17. public void run() {
18. System.out.print(”Dog”);
19. }
20. };
21. t.start();
What is the result?
A. Cat
B. Dog
C. Compilation fails.
D. The code runs with no output.
E. An exception is thrown at runtime.
Answer: B
Question 119
Click the Exhibit button.
Given:
10. public class Starter extends Thread {
11. private int x= 2;
12. public static void main(String[] args) throws Exception {
13. new Starter().makeItSo();
14. }
15. public Starter() {
16. x=5;
17. start();
18. }
19. public void makeItSo() throws Exception {
20. join();
21. x=x- 1;
22. System.out.println(x);
23. }
24. public void run() { x *= 2; }
25. }
What is the output if the main() method is rum?
A. 4
B. 5
C. 8
D. 9
E. Compilation fails.
F. An exception is thrown at runtime.
G. It is impossible to determine for certain.
Answer: D
Question 120
Given:
1. public class Threads2 implements Runnable {
2.
3. public void nun() {
4. System.out.println(”run.”);
5. throw new RuntimeException(”Problem”);
6. }
7. public static void main(String[] args) {
8. Thread t = new Thread(new Threads2());
9. t.start();
10. System.out.println(”End of method.”);
11. }
12. }
Which two can be results? (Choose two.)
A. java.lang.RuntimeException: Problem
B. run.
java.lang.RuntimeException: Problem
C. End of method.
java.lang.RuntimeException: Problem
D. End of method.
run.
java.lang.RuntimeException: Problem
E. run.
java.lang.RuntimeException: Problem
End of method.
Answer: DE
Question 121
Given:
1. public class TestOne {
2. public static void main (String[] args) throws Exception {
3. Thread.sleep(3000);
4. System.out.println(”sleep”);
5. }
6. }
What is the result?
A. Compilation fails.
B. An exception is thrown at runtime.
C. The code executes normally and prints “sleep”.
D. The code executes normally, but nothing is printed.
Answer: C
Question 122
Given:
1. public class TestOne implements Runnable {
2. public static void main (String[] args) throws Exception {
3. Thread t = new Thread(new TestOne());
4. t.start();
5. System.out.print(”Started”);
6. t.join();
7. System.out.print(”Complete”);
8. }
9. public void run() {
10. for (int i= 0; i< 4; i++) {
11. System.out.print(i);
12. }
13. }
14. }
What can be a result?
A. Compilation fails.
B. An exception is thrown at runtime.
C. The code executes and prints “StartedComplete”.
D. The code executes and prints “StartedComplete0123”.
E. The code executes and prints “Started0l23Complete”.
Answer: E
Question 123
Click the Exhibit button.
Given:
1. public class TwoThreads {
2
3. private static Object resource = new Object();
4.
5. private static void delay(long n) {
6. try { Thread.sleep(n); }
7. catch (Exception e) { System.out.print(”Error “); }
8. }
9
10. public static void main(String[] args) {
11. System.out.print(”StartMain “);
12. new Thread1().start();
13. delay(1000);
14. Thread t2 = new Thread2();
15. t2.start();
16. delay(1000);
17. t2.interrupt
18. delay(1000);
19. System.out.print(”EndMain “);
20. }
21.
22. static class Thread 1 extends Thread {
23. public void run() {
24. synchronized (resource) {
25. System.out.print(”Startl “);
26. delay(6000);
27. System.out.print(”End1 “);
28. }
29. }
30. }
31.
32. static class Thread2 extends Thread {
33. public void run() {
34. synchronized (resource) {
35. System.out.print(”Start2 “);
36. delay(2000);
37. System.out.print(”End2 “);
38. }
39. }
40. }
41. }
Assume that sleep(n) executes in exactly m milliseconds, and all other
code executes in an insignificant amount of time. What is the output if
the main() method is run?
A. Compilation fails.
B. Deadlock occurs.
C. StartMain Start1 Error EndMain End1
D. StartMain Start1 EndMain End1 Start2 End2
E. StartMain Start1 Error Start2 EndMain End2 End1
F. StartMain Start1 Start2 Error End2 EndMain End1
G. StartMain Start1 EndMain End1 Start2 Error End2
Answer: G
Question 125
Given:
public class NamedCounter {
private final String name;
private int count;
public NamedCounter(String name) { this.name = name; }
public String getName() { return name; }
public void increment() { coount++; }
public int getCount() { return count; }
public void reset() { count = 0; }
}
Which three changes should be made to adapt this class to be used
safely by multiple threads? (Choose three.)
A. declare reset() using the synchronized keyword
B. declare getName() using the synchronized keyword
C. declare getCount() using the synchronized keyword
D. declare the constructor using the synchronized keyword
E. declare increment() using the synchronized keyword
Answer: ACE
Question 125
Click the Exhibit button:
1. public class Threads 1 {
2. intx=0;
3. public class Runner implements Runnable {
4. public void run() {
5. int current = 0;
6. for(int=i=0;i<4;i++){
7. current = x;
8. System.out.print(current + “, “);
9. x = current + 2;
10. }
11. }
12. }
13.
14. public static void main(String[] args) {
15. new Threads1().go();
16. }
17.
18. public void go() {
19. Runnable r1 = new Runner();
20. new Thread(r1).start();
21. new Thread(r1 ).start();
22. }
23. }
Which two are possible results? (Choose two.)
A. 0, 2, 4, 4, 6, 8, 10, 6,
B. 0, 2, 4, 6, 8, 10, 2, 4,
C. 0, 2, 4, 6, 8, 10, 12, 14,
D. 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14,
E. 0, 2, 4, 6, 8, 10, 12, 14, 0, 2, 4, 6, 8, 10, 12, 14,
Answer: AC
Question 126
Click the Exhibit button.
1. import java.util.*;
2.
3. public class NameList {
4. private List names = new ArrayList();
5. public synchronized void add(String name) { names.add(name); }
6. public synchronized void printAll() {
7. for (int i = 0; i 8. System.out.print(names.get(i) +“ “);
9. }
10. }
11. public static void main(String[] args) {
12. final NameList sl = new NameList();
13.for(int i=0;i<2;i++) {
14. new Thread() {
15. public void ruin() {
16. sl.add(”A”);
17. sl.add(”B”);
18. sl.add(”C”);
19. sl.printAll();
20. }
21. }.start();
22. }
23. }
24. }
Which two statements are true if this class is compiled and run?
(Choose two.)
A. An exception may be thrown at runtime.
B. The code may run with no output, without exiting.
C. The code may run with no output, exiting normally.
D. The code may rum with output “A B A B C C “, then exit.
E. The code may rum with output “A B C A B C A B C “, then exit.
F. The code may ruin with output “A A A B C A B C C “, then exit.
G. The code may ruin with output “A B C A A B C A B C “, then exit.
Answer: EG
Question 127
Given:
1. public class TestFive {
2. private int x;
3. public void foo() {
4 int current = x;
5. x = current + 1;
6. }
7. public void go() {
8. for(int i=0;i<5;i++) {
9. new Thread() {
10. public void run() {
11. foo();
12. System.out.print(x + “, “);
13. } }.start();
14. }}}
Which two changes, taken together, would guarantee the output: 1, 2,
3, 4, 5, ? (Choose two.)
A. Move the line 12 print statement into the foo() method.
B. Change line 7 to public synchronized void go() {.
C. Change the variable declaration on line 3 to private volatile int x;.
D. Wrap the code inside the foo() method with a synchronized( this )
block.
E. Wrap the for loop code inside the go() method with a synchronized
block synchronized(this) { // for loop code here }.
Answer: AD
Question 128
Which three will compile and rim without exception? (Choose three.)
A. private synchronized Object o;
B. void go() {
synchronized() { /* code here */ }
}
C. public synchronized void go() { /* code here */ }
D. private synchronized(this) void go() { /* code here */ }
E. void go() {
synchronized(Object.class) { /* code here */ }
}
F. void go() {
Object o = new Object();
synchronized(o) { /* code here */ }
}
Answer: CEF
Question 129
Given:
1. public class TestSeven extends Thread {
2. private static int x;
3. public synchronized void doThings() {
4. int current = x;
5. current++;
6. x = current;
7. }
8. public void run() {
9. doThings();
10. }
1 1.}
Which is true?
A. Compilation fails.
B. An exception is thrown at runtime.
C. Synchronizing the run() method would make the class thread-safe.
D. The data in variable “x” are protected from concurrent access
problems.
E. Declaring the doThings() method as static would make the class
thread-safe.
F. Wrapping the statements within doThings() in a synchronized(new
Object()) { } block would make the class thread-safe.
Answer: E
Question 130
Click the Exhibit button.
10. public class Transfers {
11. public static void main(String[] args) throws Exception {
12. Record r1 = new Record();
13. Record r2 = new Record();
14. doTransfer(r1, r2, 5);
15. doTransfer(r2, r1, 2);
16. doTransfer(r1, r2, 1);
17. // print the result
18. System.out.println(”rl = “ + r1.get() +“, r2=” + r2.get());
19. }
20. private static void doTransfer(
21. final Record a, final Record b, final int amount) {
22. Thread t = new Thread() {
23. public void run() {
24. new Clerk().transfer(a, b, amount);
25. }
26. };
27. t.start();
28. }
29. }
30. class Clerk {
31. public synchronized void transfer(Record a, Record b, int amount){
32. synchronized (a) {
33. synchronized (b) {
34. a.add(-amount);
35. b.add(amount);
36. }
37. }
38. }
39. }
40. class Record {
41.int num=10;
42. public int get() { return num; }
43. public void add(int n) { num = num + n; }
44. }
If Transfers.main() is run, which three are true? (Choose three.)
A. The output may be “r1 = 6, r2 = 14”.
B. The output may be “r1 = 5, r2 = 15”.
C. The output may be “r1 = 8, r2 = 12”.
D. The code may run (and complete) with no output.
E. The code may deadlock (without completing) with no output.
F. M IllegalStateException or InterruptedException may be thrown at
runtime.
Answer: ABE
Question 131
Click the Exhibit button.
1. class Computation extends Thread {
2.
3. private int num;
4. private boolean isComplete;
5. private int result;
6.
7. public Computation(int num) { this.num = num; }
8.
9. public synchronized void run() {
10. result = num * 2;
11. isComplete = true;
12. notify();
13. }
14.
15. public synchronized int getResult() {
16. while (!isComplete) {
17. try {
18. wait();
19. } catch (InterruptedException e) { }
20. }
21. return result;
22. }
23.
24. public static void main(String[] args) {
25. Computation[] computations = new Computation [4];
26. for (int i = 0; i < computations.length; i++) {
27. computations[i] = new Computation(i);
28. computations[i] .start();
29. }
30. for (Computation c : computations)
31. System.out.print(c.getResult() +“ “);
32. }
33. }
What is the result?
A. The code will deadlock.
B. The code may run with no output.
C. An exception is thrown at runtime.
D. The code may run with output “0 6”.
E. The code may run with output “2 0 6 4’.
F. The code may ruin with output “0 2 4 6”.
Answer: F
Question 132
Given:
7. void waitForSignal() {
8. Object obj = new Object();
9. synchronized (Thread.currentThread()) {
10. obj.wait();
11. obj.notify();;
12. }
13. }
Which is true?
A. This code may throw an InterruptedException.
B. This code may throw an IllegalStateException.
C. This code may throw a TimeoutException after ten minutes.
D. This code will not compile unless “obj.wait()” is replaced with
“((Thread) obj).wait()”.
E. Reversing the order of obj.wait() and obj.notify() may cause this
method to complete normally.
F. A call to notify() or notifyAll() from another thread may cause this
method to complete normally.
Answer: B
Question 133
Given:
foo and bar are public references available to many other threads. foo
refers to a Thread and bar is an Object. The thread foo is currently
executing bar.wait(). From another thread, which statement is the
most reliable way to ensue that foo will stop executing wait()?
A. foo.notify();
B. bar.notify();
C. foo.notifyAll();
D. Thread.notify();
E. bar.notiFYAll();
F. Object.notify();
Answer: E
Question 134
Which two are true? (Choose two.)
A. An encapsulated, public class promotes re-use.
B. Classes that share the same interface are always tightly
encapsulated.
C. An encapsulated class allows subclasses to overload methods, but
does NOT allow overriding methods.
D. An encapsulated class allows a programmer to change an
implementation without affecting outside code.
Answer: AD
Question 135
Given:
1. package test;
2.
3. class Target {
4. public String name = “hello”;
5. }
What can directly access and change the value of the variable name?
A. any class
B. only the Target class
C. any class in the test package
D. any class that extends Target
Answer: C
Question 136
Given:
1. public class Target {
2. private int i = 0;
3. public int addOne() {
4. return ++i;
5. }
6. }
And:
1. public class Client {
2. public static void main(String[] args) {
3. System.out.println(new Target().addOne());
4. }
5. }
Which change can you make to Target without affecting Client?
A. Line 4 of class Target can be changed to return i++;
B. Line 2 of class Target can be changed to private int i = 1;
C. Line 3 of class Target can be changed to private int addOne() {
D. Line 2 of class Target can be changed to private Integer i = 0;
Answer: D
Question 137
Given:
1. package geometry;
2. public class Hypotenuse {
3. public InnerTriangle it = new InnerTriangle();
4. class InnerTriangle {
5. public int base;
6. public int height;
7. }
8. }
Which is true about the class of an object that can reference the
variable base?
A. It can be any class.
B. No class has access to base.
C. The class must belong to the geometry package.
D. The class must be a subclass of the class Hypotenuse.
Answer: C
Question 138
Given:
11. class ClassA {}
12. class ClassB extends ClassA {}
13. class ClassC extends ClassA {}
and:
21. ClassA p0 = new ClassA();
22. ClassB p1 = new ClassB();
23. ClassC p2 = new ClassC();
24. ClassA p3 = new ClassB();
25. ClassA p4 = new ClassC();
Which three are valid? (Choose three.)
A. p0 = p1;
B. p1 =p2;
C. p2 = p4;
D. p2 = (ClassC)p1;
E. p1 = (ClassB)p3;
F. p2 = (ClassC)p4;
Answer: AEF
Question 139
Given:
11. class Animal { public String noise() { return “peep”; } }
12. class Dog extends Animal {
13. public String noise() { return “bark”; }
14. }
15. class Cat extends Animal {
16. public String noise() { return “meow”; }
17. }
.....
30. Animal animal = new Dog();
31. Cat cat = (Cat)animal;
32. System.out.printIn(cat.noise());
What is the result?
A. peep
B. bark
C. meow
D. Compilation fails.
E. An exception is thrown at runtime.
Answer: E
Question 140
Given:
11. abstract class Vehicle { public int speed() { return 0; } }
12. class Car extends Vehicle { public int speed() { return 60; } }
13. class RaceCar extends Car { public int speed() { return 150; }}
......
21. RaceCar racer = new RaceCar();
22. Car car = new RaceCar();
23. Vehicle vehicle = new RaceCar();
24. System.out.println(racer.speed() + “, ‘ + car.speed()
25. + “, “+ vehicle.speed());
What is the result?
A. 0, 0,0
B. 150, 60, 0
C. Compilation fails.
D. 150, 150, 150
E. An exception is thrown at runtime.
Answer: D
Question 141
Given:
10. abstract class A {
11. abstract void al();
12. void a2() { }
13. }
14. class B extends A {
15. void a1() { }
16. void a2() { }
17. }
18. class C extends B { void c1() { } }
and:
A x = new B(); C y = new C(); A z = new C();
Which four are valid examples of polymorphic method calls? (Choose
four.)
A. x.a2();
B. z.a2();
C. z.c1();
D. z.a1();
E. y.c1();
F. x.a1();
Answer: ABDF
Question 142
Given:
10. interface A { void x(); }
11. class B implements A { public void x() { } public voidy() { } }
12. class C extends B { public void x() {} }
And:
20. java.util.List list = new java.util.ArrayList();
21. list.add(new B());
22. list.add(new C());
23. for (A a:list) {
24. a.x();
25. a.y();;
26. }
What is the result?
A. The code runs with no output.
B. An exception is thrown at runtime.
C. Compilation fails because of an error in line 20.
D. Compilation fails because of an error in line 21.
E. Compilation fails because of an error in line 23.
F. Compilation fails because of an error in line 25.
Answer: F
Question 143
Given:
1. class SuperClass {
2. public A getA() {
3. return new A();
4. }
5. }
6. class SubClass extends SuperClass {
7. public B getA() {
8. return new B();
9. }
10. }
Which is true?
A. Compilation will succeed if A extends B.
B. Compilation will succeed if B extends A.
C. Compilation will always fail because of an error in line 7.
D. Compilation will always fail because of an error in line 8.
Answer: B
Question 144
Given:
1. interface A { public void aMethod(); }
2. interface B { public void bMethod(); }
3. interface C extends A,B { public void cMethod(); }
4. class D implements B {
5. public void bMethod() { }
6. }
7. class E extends D implements C {
8. public void aMethod() { }
9. public void bMethod() { }
10. public void cMethod() { }
11. }
What is the result?
A. Compilation fails because of an error in line 3.
B. Compilation fails because of an error in line 7.
C. Compilation fails because of an error in line 9.
D. If you define D e = new E(), then e.bMethod() invokes the version
of bMethod() defined in Line 5.
E. If you define D e = (D)(new E()), then e.bMethod() invokes the
version of bMethod() defined in Line 5.
F. If you define D e = (D)(new E()), then e.bMethod() invokes the
version of bMethod() defined in Line 9.
Answer: F
Question 145
Given:
10. interface A { public int getValue() }
11. class B implements A {
12. public int getValue() { return 1; }
13. }
14. class C extends B {
15. // insert code here
16. }
Which three code fragments, inserted individually at line 15, make use
of polymorphism? (Choose three.)
A. public void add(C c) { c.getValue(); }
B. public void add(B b) { b.getValue(); }
C. public void add(A a) { a.getValue(); }
D. public void add(A a, B b) { a.getValue(); }
E. public void add(C c1, C c2) { c1.getValue(); }
Answer: BCD
Question 146
Given:
1. class ClassA {
2. public int numberOfinstances;
3. protected ClassA(int numberOfinstances) {
4. this.numberOflnstances = numberOfinstances;
5. }
6. }
7. public class ExtendedA extends ClassA {
8. private ExtendedA(int numberOfinstances) {
9. super(numberOflnstances);
10. }
11. public static void main(String[] args) {
12. ExtendedA ext = new ExtendedA(420);
13. System.out.print(ext.numberOflnstances);
14. }
15. }
Which is true?
A. 420 is the output.
B. An exception is thrown at runtime.
C. All constructors must be declared public.
D. Constructors CANNOT use the private modifier.
E. Constructors CANNOT use the protected modifier.
Answer: A
Question 147
147. Given:
1. public class Base {
2. public static final String FOO = “foo”;
3. public static void main(String[] args) {
4. Base b = new Base();
5. Sub s = new Sub();
6. System.out.print(Base.FOO);
7. System.out.print(Sub.FOO);
8. System.out.print(b.FOO);
9. System.out.print(s.FOO);
10. System.out.print(((Base)s).FOO);
11. } }
12. class Sub extends Base {public static final String FOO=bar;}
What is the result?
A. foofoofoofoofoo
B. foobarfoobarbar
C. foobarfoofoofoo
D. foobarfoobarfoo
E. barbarbarbarbar
F. foofoofoobarbar
G. foofoofoobarfoo
Answer: D
Question 148
Which three statements are true? (Choose three.)
A. A final method in class X can be abstract if and only if X is abstract.
B. A protected method in class X can be overridden by any subclass of
X.
C. A private static method can be called only within other static
methods in class X.
D. A non-static public final method in class X can be overridden in any
subclass of X.
E. A public static method in class X can be called by a subclass of X
without explicitly referencing the class X.
F. A method with the same signature as a private final method in class
X can be implemented in a subclass of X.
G. A protected method in class X can be overridden by a subclass of A
only if the subclass is in the same package as X.
Answer: BEF
Question 149
Given:
1. class Pizza {
2. java.util.ArrayList toppings;
3. public final void addTopping(String topping) {
4. toppings.add(topping);
5. }
6. }
7. public class PepperoniPizza extends Pizza {
8. public void addTopping(String topping) {
9. System.out.println(”Cannot add Toppings”);
10. }
11. public static void main(String[] args) {
12. Pizza pizza = new PepperoniPizza();
13. pizza.addTopping(”Mushrooms”);
14. }
15. }
What is the result?
A. Compilation fails.
B. Cannot add Toppings
C. The code runs with no output.
D. A NullPointerException is thrown in Line 4.
Answer: A
Question 150
Given:
1. class Super {
2. private int a;
3. protected Super(int a) { this.a = a; }
4. }
.....
11. class Sub extends Super {
12. public Sub(int a) { super(a); }
13. public Sub() { this.a= 5; }
14. }
Which two, independently, will allow Sub to compile? (Choose two.)
A. Change line 2 to:
public int a;
B. Change line 2 to:
protected int a;
C. Change line 13 to:
public Sub() { this(5); }
D. Change line 13 to:
public Sub() { super(5); }
E. Change line 13 to:
public Sub() { super(a); }
Answer: CD
Question 151
Click the Exhibit button.
1. public class SimpleCalc {
2. public int value;
3. public void calculate() { value += 7; }
4. }
And:
1. public class MultiCalc extends SimpleCalc {
2. public void calculate() { value -= 3; }
3. public void calculate(int multiplier) {
4. calculate();
5. super.calculate();
6. value *=multiplier;
7. }
8. public static void main(String[] args) {
9. MultiCalc calculator = new MultiCalc();
10. calculator.calculate(2);
11. System.out.println(”Value is: “+ calculator.value);
12. }
13. }
What is the result?
A. Value is: 8
B. Compilation fails.
C. Value is: 12
D. Value is: -12
E. The code runs with no output.
F. An exception is thrown at runtime.
Answer: A
Question 152
Given:
10. public class Hello {
11. String title;
12. int value;
13. public Hello() {
14. title += “ World”;
15. }
16. public Hello(int value) {
17. this.value = value;
18. title = “Hello”;
19. Hello();
20. }
21. }
and:
30. Hello c = new Hello(5);
31. System.out.println(c.title);
What is the result?
A. Hello
B. Hello World
C. Compilation fails.
D. Hello World 5
E. The code runs with no output.
F. An exception is thrown at runtime.
Answer: C
Question 153
Click the Exhibit button.
1. public class Car {
2. private int wheelCount;
3. private String vin;
4. public Car(String vin) {
5. this.vin = vin;
6. this.wheelCount = 4;
7. }
8. public String drive() {
9. return “zoom-zoom”;
10. }
11. public String getInfo() {
12. return “VIN: “+ vin + “wheels: “+ wheelCount;
13. }
14. }
And:
1. public class MeGo extends Car {
2. public MeGo(String vin) {
3. this.wheelCount = 3;
4. }
5. }
What two must the programmer do to correct the compilation errors?
(Choose two.)
A. insert a call to this() in the Car constructor
B. insert a call to this() in the MeGo constructor
C. insert a call to super() in the MeGo constructor
D. insert a call to super(vin) in the MeGo constructor
E. change the wheelCount variable in Car to protected
F. change line 3 in the MeGo class to super.wheelCount = 3;
Answer: DE
Question 154
Click the Exhibit button.
1. public class Employee {
2. String name;
3. double baseSalary;
4. Employee(String name, double baseSalary) {
5. this.name = name;
6. this.baseSalary = baseSalary;
7. }
8. }
And:
1. public class Salesperson extends Employee {
2. double commission;
3. public Salesperson(String name, double baseSalary,
4. double commission) {
5. // insert code here
6. }
7. }
Which code, inserted at line 7, completes the Salesperson constructor?
A. this.commission = commission;
B. superb();
commission = commission;
C. this.commission = commission;
superb();
D. super(name, baseSalary);
this.commission = commission;
E. super();
this.commission = commission;
F. this.commission = commission;
super(name, baseSalary);
Answer: D
Question 155
Given:
1. public class Blip {
2. protected int blipvert(int x) { return 0; }
3. }
4. class Vert extends Blip {
5. // insert code here
6. }
Which five methods, inserted independently at line 5, will compile?
(Choose five.)
A. public int blipvert(int x) { return 0; }
B. private int blipvert(int x) { return 0; }
C. private int blipvert(long x) { return 0; }
D. protected long blipvert(int x) { return 0; }
E. protected int blipvert(long x) { return 0; }
F. protected long blipvert(long x) { return 0; }
G. protected long blipvert(int x, int y) { return 0; }
Answer: ACEFG
Question156
Given:
10. public class Foo {
11. public int a;
12. public Foo() { a = 3; }
13. public void addFive() { a += 5; }
14. }
and:
20. public class Bar extends Foo {
21. public int a;
22. public Bar() { a = 8; }
23. public void addFive() { this.a +=5; }
24. }
invoked with:
30. Foo foo = new Bar();
31. foo.addFive();
32. System.out.println(”Value: “+ foo.a);
What is the result?
A. Value: 3
B. Value: 8
C. Value: 13
D. Compilation fails.
E. The code runs with no output.
F. An exception is thrown at runtime.
Answer: A
Question 157
Given:
10. public class SuperCaic {
11. protected static int multiply(int a, int b) { return a * b; }
12. }
and:
20. public class SubCalc extends SuperCalc {
21. public static int multiply(int a, int b) {
22. int c = super.multiply(a, b);
23. return c;
24. }
25. }
and:
30. SubCalc sc = new SubCalc();
31. System.out.println(sc.multiply(3,4));
32. System.out.println(SubCalc.multiply(2,2));
What is the result?
A. 12
4
B. The code runs with no output.
C. An exception is thrown at runtime.
D. Compilation fails because of an error in line 21.
E. Compilation fails because of an error in line 22.
F. Compilation fails because of an error in line 31.
Answer: E
Question 158
Given:
1. public class Team extends java.util.LinkedList {
2. public void addPlayer(Player p) {
3. add(p);
4. }
5. public void compete(Team opponent) { /* more code here */ }
6. }
7. class Player { /* more code here */ }
Which two are true? (Choose two.)
A. This code will compile.
B. This code demonstrates proper design of an is-a relationship.
C. This code demonstrates proper design of a has-a relationship.
D. A Java programmer using the Team class could remove Player
objects from a Team object.
Answer: AD
Question 159
Which four are true? (Choose four.)
A. Has-a relationships should never be encapsulated.
B. Has-a relationships should be implemented using inheritance.
C. Has-a relationships can be implemented using instance variables.
D. Is-a relationships can be implemented using the extends keyword.
E. Is-a relationships can be implemented using the implements
keyword.
F. The relationship between Movie and Actress is an example of an is-a
relationship.
G. An array or a collection can be used to implement a one-to-many
has-a relationship.
Answer: CDEG
Question 160
Which two are true about has-a and is-a relationships? (Choose two.)
A. Inheritance represents an is-a relationship.
B. Inheritance represents a has-a relationship.
C. Interfaces must be used when creating a has-a relationship.
D. Instance variables can be used when creating a has-a relationship.
Answer: AD
Question 161
Given:
10. interface Jumper { public void jump(); }
......
20. class Animal {}
......
30. class Dog extends Animal {
31. Tail tail;
32. }
......
40. class Beagle extends Dog implements Jumper {
41. public void jump() { }
42. }
.......
50. class Cat implements Jumper {
51. public void jump() { }
52. }
Which three are true? (Choose three.)
A. Cat is-a Animal
B. Cat is-a Jumper
C. Dog is-a Animal
D. Dog is-a Jumper
E. Cat has-a Animal
F. Beagle has-a Tail
G. Beagle has-a Jumper
Answer: BCF
Question 162
Given:
1. import java.util.*;
2. public class Example {
3. public static void main(String[] args) {
4. // insert code here
5. set.add(new integer(2));
6. set.add(new integer(l));
7. System.out.println(set);
8. }
9. }
Which code, inserted at line 4, guarantees that this program will
output [1, 2]?
A. Set set = new TreeSet();
B. Set set = new HashSet();
C. Set set = new SortedSet();
D. List set = new SortedList();
E. Set set = new LinkedHashSet();
Answer: A
Question 163
Given:
1. import java.util.*;
2. public class PQ {
3. public static void main(String[] args) {
4. PriorityQueue pq = new PriorityQueue();
5. pq.add(”carrot”);
6. pq.add(”apple”);
7. pq.add(”banana”);
8. System.out.println(pq.poll() +”:” + pq.peek());
9. }
10. }
What is the result?
A. apple:apple
B. carrot:apple
C. apple:banana
D. banana:apple
E. carrot:carrot
F. carrot:banana
Answer: C
Question 164
Given:
1. import java.util.*;
2. public class WrappedString {
3. private String s;
4. public WrappedString(String s) { this.s = s; }
5. public static void main(String[] args) {
6. HashSet hs = new HashSet();
7. WrappedString ws1 = new WrappedString(”aardvark”);
8. WrappedString ws2 = new WrappedString(”aardvark”);
9. String s1 = new String(”aardvark”);
10. String s2 = new String(”aardvark”);
11. hs.add(ws1); hs.add(ws2); hs.add(s1); hs.add(s2);
12. System.out.println(hs.size()); } }
What is the result?
A. 0
B. 1
C. 2
D. 3
E. 4
F. Compilation fails.
G. An exception is thrown at runtime.
Answer: D
Question 165
Click the Exhibit button.
1. import java.util.*;
2. public class TestSet {
3. enum Example { ONE, TWO, THREE }
4. public static void main(String[] args) {
5. Collection coll = new ArrayList();
6. coll.add(Example.THREE);
7. coll.add(Example.THREE);
8. coll.add(Example.THREE);
9. coll.add(Example.TWO);
10. coll.add(Example.TWO);
11. coll.add(Example.ONE);
12. Set set = new HashSet(coll);
13. }
14. }
Which statement is true about the set variable on line 12?
A. The set variable contains all six elements from the coll collection,
and the order is guaranteed to be preserved.
B. The set variable contains only three elements from the coll
collection, and the order is guaranteed to be preserved.
C. The set variable contains all six elements from the coil collection,
but the order is NOT guaranteed to be preserved.
D. The set variable contains only three elements from the coil
collection, but the order is NOT guaranteed to be preserved.
Answer: D
Question 166
Given:
1. public class Score implements Comparable {
2. private int wins, losses;
3. public Score(int w, int 1) { wins = w; losses = 1; }
4. public int getWins() { return wins; }
5. public int getLosses() { return losses; }
6. public String toString() {
7. return “<“ + wins + “,“ + losses + “>”;
8. }
9. // insert code here
10. }
Which method will complete this class?
A. public int compareTo(Object o) {/*mode code here*/}
B. public int compareTo(Score other) {/*more code here*/}
C. public int compare(Score s1,Score s2){/*more code here*/}
D. public int compare(Object o1,Object o2){/*more code here*/}
Answer: B
Question 167
A programmer has an algorithm that requires a java.util.List that
provides an efficient implementation of add(0,object), but does
NOT need to support quick random access. What supports these
requirements?
A. java.util.Queue
B. java.util.ArrayList
C. java.util.LinearList
D. java.util.LinkedList
Answer: D
Question 168
Given:
11. public class Person {
12. private String name, comment;
13. private int age;
14. public Person(String n, int a, String c) {
15. name = n; age = a; comment = c;
16. }
17. public boolean equals(Object o) {
18. if(! (o instanceof Person)) return false;
19, Person p = (Person)o;
20. return age == p.age && name.equals(p.name);
21. }
22. }
What is the appropriate definition of the hashCode method in class
Person?
A. return super.hashCode();
B. return name.hashCode() + age * 7;
C. return name.hashCode() + comment.hashCode() /2;
D. return name.hashCode() + comment.hashCode() / 2 - age * 3;
Answer: B
Question 169
Given:
11. public class Key {
12. private long id1;
13. private long 1d2;
14.
15. // class Key methods
16. }
A programmer is developing a class Key, that will be used as a key in
a standard java.util.HashMap. Which two methods should be
overridden to assure that Key works correctly as a key? (Choose two.)
A. public int hashCode()
B. public boolean equals(Key k)
C. public int compareTo(Object o)
D. public boolean equals(Object o)
E. public boolean compareTo(Key k)
Answer: AD
Question 170
Given:
11. public class Person {
12. private name;
13. public Person(String name) {
14. this.name = name;
15. }
16. public boolean equals(Object o) {
17. if( !o instanceof Person ) return false;
18. Person p = (Person) o;
19. return p.name.equals(this.name);
20. }
21. }
Which is true?
A. Compilation fails because the hashCode method is not overridden.
B. A HashSet could contain multiple Person objects with the same
name.
C. All Person objects will have the same hash code because the
hashCode method is not overridden.
D. If a HashSet contains more than one Person object with
name=”Fred”, then removing another Person, also with name=”Fred”,
will remove them all.
Answer: B
Question 171
Given:
1. public class Person {
2. private String name;
3. public Person(String name) { this.name = name; }
4. public boolean equals(Person p) {
5. return p.name.equals(this.name);
6. }
7. }
Which is true?
A. The equals method does NOT properly override the Object.equals
method.
B. Compilation fails because the private attribute p.name cannot be
accessed in line 5.
C. To work correctly with hash-based data structures, this class must
also implement the hashCode method.
D. When adding Person objects to a java.util.Set collection, the equals
method in line 4 will prevent duplicates.
Answer: A
Question 172
Which two statements are true about the hashCode method? (Choose
two.)
A. The hashCode method for a given class can be used to test for
object equality and object inequality for that class.
B. The hashCode method is used by the java.util.SortedSet collection
class to order the elements within that set.
C. The hashCode method for a given class can be used to test for
object inequality, but NOT object equality, for that class.
D. The only important characteristic of the values returned by a
hashCode method is that the distribution of values must follow a
Gaussian distribution.
E. The hashCode method is used by the java.util.HashSet collection
class to group the elements within that set into hash buckets for
swift retrieval.
Answer: CE
Question 173
Given:
enum Example { ONE, TWO, THREE }
Which is true?
A. The expressions (ONE == ONE) and ONE.equals(ONE) are both
guaranteed to be true.
B. The expression (ONE < TWO) is guaranteed to be true and
ONE.compareTo(TWO) is guaranteed to be less than one.
C. The Example values cannot be used in a raw java.util.HashMap;
instead, the programmer must use a java.util.EnumMap.
D. The Example values can be used in a java.util.SortedSet, but the
set will NOT be sorted because enumerated types do NOT implement
java.lang.Comparable.
Answer: A
Question 174
Click the Exhibit button.
1. import java.util.*;
2. class KeyMaster {
3. public int i;
4. public KeyMaster(int i) { this.i = i; }
5. public boolean equals(Object o) { return i == ((KeyMaster)o).i; }
6. public int hashCode() { return i; }
7. }
8. public class MapIt {
9. public static void main(String[] args) {
10. Set set = new HashSet();
11. KeyMaster k1 = new KeyMaster(1);
12. KeyMaster k2 = new KeyMaster(2);
13. set.add(k1); set.add(k1);
14. set.add(k2); set.add(k2);
15. System.out.print(set.size() + “:”);
16. k2.i = 1;
17. System.out.print(set.size() + “:”);
18. set.remove(k1);
19. System.out.print(set.size() + “:”);
20. set.remove(k2);
21. System.out.print(set.size());
22. }
23. }
What is the result?
A. 4:4:2:2
B. 4:4:3:2
C. 2:2:1:0
D. 2:2:0:0
E. 2:1:0:0
F. 2:2:1:1
G. 4:3:2:1
Answer: F
Question 175
Given:
1. import java.util.*;
2. public class Test {
3. public static void main(String[] args) {
4. List strings = new ArrayList();
5. // insert code here
6. }
7. }
Which four, inserted at line 5, will allow compilation to succeed?
(Choose four.)
A. String s = strings.get(0);
B. Iterator i1 = strings.iterator();
C. String[] array1 = strings.toArray();
D. Iterator i2 = strings.iterator();
E. String[] array2 = strings.toArray(new String[1]);
F. Iterator i3 = strings.iterator();
Answer: ABDE
Question 176
Given:
1. import java.util.*;
2. public class Old {
3. public static Object get()(List list) {
4. return list.get(0);
5. }
6. }
Which three will compile successfully? (Choose three.)
A. Object o = Old.get0(new LinkedList());
B. Object o = Old.get0(new LinkedList());
C. String s = Old.getfl(new LinkedList());
D. Object o = Old.get0(new LinkedList());
E. String s = (String)Old.get0(new LinkedList());
Answer: ADE
Question 177
Given:
11. public static void append(List list) { list.add(”0042”); }
12. public static void main(String[] args) {
13. List intList = new ArrayList();
14. append(intList);
15. System.out.println(intList.get(0));
16. }
‘What is the result?
A. 42
B. 0042
C. An exception is thrown at runtime.
D. Compilation fails because of an error in line 13.
E. Compilation fails because of an error in line 14.
Answer: B
Question 178
Given a pre-generics implementation of a method:
11. public static int sum(List list) {
12. int sum = 0;
13. for ( Iterator iter = list.iterator(); iter.hasNext(); ) {
14. int i = ((Integer)iter.next()).intValue();
15. sum += i;
16. }
17. return sum;
18. }
Which three changes must be made to the method sum to use
generics? (Choose three.)
A. remove line 14
B. replace line 14 with “int i = iter.next();”
C. replace line 13 with “for (int i : intList) {“
D. replace line 13 with “for (Iterator iter : intList) {“
E. replace the method declaration with “sum(List intList)”
F. replace the method declaration with “sum(List intList)”
Answer: ACF
Question 179
Given:
classA {}
class B extends A {}
class C extends A {}
class D extends B {}
Which three statements are true? (Choose three.)
A. The type List is assignable to List.
B. The type List is assignable to List
.
C. The type List is assignable to List.
D. The type List is assignable to List.
E. The type List is assignable to List.
F. The type List is assignable to any List reference.
G. The type List is assignable to List.
Answer: CDG
Question 180
Given:
11. public void addStrings(List list) {
12. list.add(”foo”);
13. list.add(”bar”);
14. }
What must you change in this method to compile without warnings?
A. add this code after line 11:
list = (List) list;
B. change lines 12 and 13 to:
list.add(”foo”);
list.add(”bar”);
C. change the method signature on line 11 to:
public void addStrings(List list) {
D. change the method signature on line 11 to:
public void addStrings(List list) {
E. No changes are necessary. This method compiles without warnings.
Answer: D
Question 181
Given:
1. public class Test {
2. public T findLarger(T x, T y) {
3. if(x.compareTo(y) > 0) {
4. return x;
5. } else {
6. return y;
7. }
8. }
9. }
and:
22. Test t = new Test();
23. // insert code here
Which two will compile without errors when inserted at line 23?
(Choose two.)
A. Object x = t.findLarger(123, “456”);
B. int x = t.findLarger(123, new Double(456));
C. int x = t.findLarger(123, new Integer(456));
D. int x = (int) t.findLarger(new Double(123), new Double(456));
Answer: AC
Question 182
Given:
11. // insert code here
12. private N min, max;
13. public N getMin() { return min; }
14. public N getMax() { return max; }
15. public void add(N added) {
16. if (min == null || added.doubleValue() 17. min = added;
18. if (max == null ||added.doubleValue() > max.doubleValue())
19. max = added;
20. }
21. }
Which two, inserted at line 11, will allow the code to compile? (Choose
two.)
A. public class MinMax {
B. public class MinMax {
C. public class MinMax {
D. public class MinMax {
E. public class MinMax {
F. public class MinMax {
Answer: DF
Question 183
A programmer must create a generic class MinMax and the type
parameter of MinMax must implement Comparable. Which
implementation of MinMax will compile?
A. class MinMax> {
E min=null;
E max=null;
public MinMax() { }
public void put(E value) { /* store min or max */ }
}
B. class MinMax> {
E min=null;
E max=null;
public MinMax() { }
public void put(E value) { /* store min or max */ }
}
C. class MinMax> {
E min = null;
E max = null;
public MinMax() { }
public void put(E value) { /* store min or max */ }
}
D. class MinMax> {
E min = null;
E max = null;
public MinMax() { }
public void put(E value) { /* store min or max */ }
}
Answer: A
Question 184
Given:
1. public class Drink implements Comparable {
2. public String name;
3. public int compareTo(Object o) {
4. return 0;
5. }
6. }
and:
20. Drink one = new Drink();
21. Drink two = new Drink();
22. one.name= “Coffee”;
23. two.name= “Tea”;
23. TreeSet set = new TreeSet();
24. set.add(one);
25. set.add(two);
A programmer iterates over the TreeSet and prints the name of each
Drink object.
What is the result?
A. Tea
B. Coffee
C. Coffee
Tea
D. Compilation fails.
E. The code runs with no output.
F. An exception is thrown at runtime.
Answer: B
Question 185
Given:
11. List list = // more code here
12. Collections.sort(list, new MyComparator());
Which code will sort this list in the opposite order of the sort in line
12?
A. Collections.reverseSort(list, new MyComparator());
B. Collections.sort(list, new MyComparator());
list.reverse();
C. Collections.sort(list, new InverseComparator(
new MyComparator()));
D. Collections.sort(list, Collections.reverseOrder(
new MyComparator()));
Answer: D
Question 186
Given:
int[] myArray=newint[] {1, 2,3,4, 5};
What allows you to create a list from this array?
A. List myList = myArray.asList();
B. List myList = Arrays.asList(myArray);
C. List myList = new ArrayList(myArray);
D. List myList = Collections.fromArray(myArray);
Answer: B
Question 187
Given:
13. public static void search(List list) {
14. list.clear();
15. list.add(”b”);
16. list.add(”a”);
17. list.add(”c”);
18. System.out.println(Collections.binarySearch(list, “a”));
19. }
What is the result of calling search with a valid List implementation?
A. 0
B. 1
C. 2
D. a
E. b
F. c
G. The result is undefined.
Answer: G
Question 188
Given:
1. import java.util.*;
2.
3. public class LetterASort {
4. public static void main(String[] args) {
5. ArrayList strings = new ArrayList();
6. strings.add(’aAaA”);
7. strings.add(”AaA”);
8. strings.add(’aAa”);
9. strings.add(”AAaa”);
10. Collections.sort(strings);
11. for (String s: strings) { System.out.print(s + “ “); }
12. }
13. }
What is the result?
A. Compilation fails.
B. aAaA aAa AAaa AaA
C. AAaa AaA aAa aAaA
D. AaA AAaa aAaA aAa
E. aAa AaA aAaA AAaa
F. An exception is thrown at runtime.
Answer: C
Question 189
Given:
ArrayList a = new ArrayList();
containing the values {“1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”}
Which code will return 2?
A. Collections. sort(a, a.reverse());
int result = Collections.binarySearch(a, “6”);
B. Comparator c = Collections.reverseOrder();
Collections.sort(a, c);
int result = Collections.binarySearch(a, “6”);
C. Comparator c = Collections.reverseOrder();
Collections.sort(a, c);
int result = Collections.binarySearch(a, “6”,c);
D. Comparator c = Collections.reverseOrder(a);
Collections.sort(a, c);
int result = Collections.binarySearch(a, “6”,c);
E. Comparator c = new InverseComparator(new Comparator());
Collections.sort(a);
int result = Collections.binarySearch(a, “6”,c);
Answer: C
Question 190
Given:
34. HashMap props = new HashMap();
35. props.put(”key45”, “some value”);
36. props.put(”key12”, “some other value”);
37. props.put(”key39”, “yet another value”);
38. Set s = props.keySet();
39. // insert code here
What, inserted at line 39, will sort the keys in the props HashMap?
A. Arrays.sort(s);
B. s = new TreeSet(s);
C. Collections.sort(s);
D. s = new SortedSet(s);
Answer: B
Question 191
Given classes defined in two different files:
1. package util;
2. public class BitUtils {
3. public static void process(byte[]) { /* more code here */ }
4. }
1. package app;
2. public class SomeApp {
3. public static void main(String[] args) {
4. byte[] bytes = new byte[256];
5. // insert code here
6. }
7. }
What is required at line 5 in class SomeApp to use the process method
of BitUtils?
A. process(bytes);
B. BitUtils.process(bytes);
C. util.BitUtils.process(bytes);
D. SomeApp cannot use methods in BitUtils.
E. import util.BitUtils.*; process(bytes);
Answer: C
Question
Given classes defined in two different files:
1. package util;
2. public class BitUtils {
3. private static void process(byte[] b) { }
4. }
1. package app;
2. public class SomeApp {
3. public static void main(String[] args) {
4. byte[] bytes = new byte[256];
5. // insert code here
6. }
7. }
What is required at line 5 in class SomeApp to use the process method
of BitUtils?
A. process(bytes);
B. BitUtils.process(bytes);
C. app.BitUtils.process(bytes);
D. util.BitUtils.process(bytes);
E. import util.BitUtils. *; process(bytes);
F. SomeApp cannot use the process method in BitUtils.
Answer: F
Question 193
Given classes defined in two different files:
1. package packageA;
2. public class Message {
3. String getText() { return “text”; }
4. }
and:
1. package packageB;
2. public class XMLMessage extends packageA.Message {
3. String getText() { return “text”; }
4. public static void main(String[] args) {
5. System.out.println(new XMLMessage().getText());
6. }
7. }
What is the result of executing XMLMessage.main?
A. text
B. text
C. An exception is thrown at runtime.
D. Compilation fails because of an error in line 2 of XMLMessage.
E. Compilation fails because of an error in line 3 of XMLMessage.
Answer: E
Question 194
Given a file GrizzlyBear.java:
1. package animals.mammals;
2.
3. public class GrizzlyBear extends Bear {
4. void hunt() {
5. Salmon s = findSalmon();
6. s.consume();
7. }
8. }
and another file, Salmon.java:
1. package animals.fish;
2.
3. public class Salmon extends Fish {
4. void consume() { /* do stuff */ }
5. }
Assume both classes are defined in the correct directories for theft
packages, and that the Mammal class correctly defines the
findSalmon() method. Which two changes allow this code to compile
correctly? (Choose two.)
A. add public to the start of line 4 in Salmon.java
B. add public to the start of line 4 in GrizzlyBear.java
C. add import animals.mammals.*; at line 2 in Salmon.java
D. add import animals.fish.*; at line 2 in GrizzlyBear.java
E. add import animals.fish.Salmon.*; at line 2 in GrizzlyBear.java
F. add import animals.mammals.GrizzlyBear.*;at line 2 in Salmon.java
Answer: AD
Question 195
Given a class Repetition:
1. package utils;
2.
3. public class Repetition {
4. public static String twice(String s) { return s + s; }
5. }
and given another class Demo:
1. // insert code here
2.
3. public class Demo {
4. public static void main(String[] args) {
5. System.out.println(twice(”pizza”));
6. }
7. }
Which code should be inserted at line 1 of Demo.java to compile and
run Demo to print “pizzapizza”?
A. import utils.*;
B. static import utils.*;
C. import utils.Repetition.*;
D. static import utils.Repetition. *;
E. import utils.Repetition.twice();
F. import static utils.Repetition.twice;
G. static import utils.Repetition.twice;
Answer: F
Question 196
Given:
11. interface DeclareStuff{
12. public static final int EASY = 3;
13. void doStuff(int t); }
14. public class TestDeclare implements DeclareStuff {
15. public static void main(String [] args) {
16. int x=5;
17. new TestDeclare().doStuff(++x);
18. }
19. void doStuff(int s) {
20. s += EASY + ++s;
21. System.out.println(”s “ + s);
22. }
23. }
What is the result?
A. s 14
B. s 16
C. s 10
D. Compilation fails.
E. An exception is thrown at runtime.
Answer: D
Question 197
Given:
1. interface DoStuff2 {
2. float getRange(int low, int high); }
3.
4. interface DoMore {
5. float getAvg(int a, int b, int c); }
6.
7. abstract class DoAbstract implements DoStuff2, DoMore { }
8.
9. class DoStuff implements DoStuff2 {
10. public float getRange(int x, int y) { return 3.14f; } }
11.
12. interface DoAll extends DoMore {
13. float getAvg(int a, int b, int c, int d); }
What is the result?
A. The file will compile without error.
B. Compilation fails. Only line 7 contains an error.
C. Compilation fails. Only line 12 contains an error.
D. Compilation fails. Only line 13 contains an error.
E. Compilation fails. Only lines 7 and 12 contain errors.
F. Compilation fails. Only lines 7 and 13 contain errors.
G. Compilation fails. Lines 7, 12, and 13 contain errors.
Answer: A
Question 198
Given:
11. public class Counter {
12. public static void main(String[] args) {
13. int numArgs = /* insert code here */;
14. }
15. }
and the command line:
java Counter one fred 42
Which code, inserted at line 13, captures the number of arguments
passed into the program?
A. args.count
B. args.length
C. args.count()
D. args.length()
E. args.getLength()
Answer: B
Question 199
Given a correctly compiled class whose source code is:
1. package com.sun.sjcp;
2. public class Commander {
3. public static void main(String[] args) {
4. // more code here
5. }
6. }
Assume that the class file is located in /foo/com/sun/sjcp/, the current
directory is /foo/, and that the classpath contains “.“ (current
directory).
Which command line correctly runs Commander?
A. java Commander
B. java com. sim. sjcp.Commander
C. java com/sun/sjcp/Commander
D. java -cp com.sun.sjcp Commander
E. java -cp com/sun/sjcp Commander
Answer: B
Question 200
Given the command line java Pass2 and:
15. public class Pass2 {
16. public void main(String [] args) {
17.int x=6;
18. Pass2 p = new Pass2();
19. p.doStuff(x);
20. System.out.print(” main x = “+ x);
21. }
22.
23. void doStuff(int x) {
24. System.out.print(” doStuffx = “+ x++);
25. }
26. }
What is the result?
A. Compilation fails.
B. An exception is thrown at runtime.
C. doStuffx = 6 main x = 6
D. doStuffx = 6 main x = 7
E. doStuffx = 7 main x = 6
F. doStuffx = 7 main x = 7
Answer: B
Question 201
Given:
15. public class Yippee {
16. public static void main(String [] args) {
17. for(int x = 1; x < args.length; x++) {
18. System.out.print(args[x] +“ “);
19. }
20. }
21. }
and two separate command line invocations:
java Yippee
java Yippee 1234
What is the result?
A. No output is produced.
123
B. No output is produced.
234
C. No output is produced.
1234
D. An exception is thrown at runtime.
123
E. An exception is thrown at runtime.
234
F. An exception is thrown at rijntime.
1234
Answer: B
Question 202
Given:
12. public class Yippee2 {
13.
14. static public void main(String [] yahoo) {
15. for(int x= 1; x16. System.out.print(yahoo[x] + “ “);
17. }
18. }
19. }
and the command line invocation:
java Yippee2 a b c
What is the result?
A.a b
B.b c
C.a b c
D. Compilation fails.
E. An exception is thrown at runtime.
Answer: B
Question 203
Given:
11. public class Commander {
12. public static void main(String[] args) {
13. String myProp = /* insert code here */
14. System.out.println(myProp);
15. }
16. }
and the command line:
java -Dprop.custom=gobstopper Commander
Which two, placed on line 13, will produce the output gobstopper?
(Choose two.)
A. System.load(”prop.custom”);
B. System.getenv(”prop.custom”);
C. System.property(”prop.custom”);
D. System.getProperty(”prop.custom”);
E. System.getProperties().getProperty(”prop.custom”);
Answer: DE
Question 204
Click the Exhibit button.
11. class Payload {
12. private int weight;
13. public Payload(int wt) { weight = wt; }
13. public void setWeight(mt w) { weight = w; }
15. public String toString { return Integer.toString(weight); }
16. }
17.
18. public class TestPayload {
19. static void changePayload(Payload p) {
20. /* insert code here */
21. }
22.
23. public static void main(String[] args) {
24. Payload p = new Payload();
25. p.setWeight(1024);
26. changePayload(p);
27. System.out.println(”The value of p is “+ p);
28. }
29. }
Which statement, placed at line 20, causes the code to print “The
value of p is 420.”?
A. p.setWeight(420);
B. p.changePayload(420);
C. p = new Payload(420);
D. Payload.setWeight(420);
E. p = Payload.setWeight(420);
F. p = new Payload();
p.setWeight(420);
Answer: A
Question 205
Click the Exhibit button.
1. public class Item {
2. private String desc;
3. public String getDescription() { return desc; }
4. public void setDescription(String d) { desc = d; }
5.
6. public static void modifyDesc(Item item, String desc) {
7. item = new Item();
8. item.setDescription(desc);
9. }
10. public static void main(String[] args) {
11. Item it = new Item();
12. it.setDescription(”Gobstopper”);
13. Item it2 = new Item();
14. it2.setDescription(”Fizzylifting”);
15. modifyDesc(it, “Scrumdiddlyumptious”);
16. System.out.println(it.getDescription());
17. System.out.println(it2.getDescription());
18. }
19. }
What is the outcome of the code?
A. Compilation fails.
B. Gobstopper
Fizzylifting
C. Gobstopper
Scrumdiddlyumptious
D. Scrumdiddlyumptious
Fizzylifltng
E. Scrumdiddlyumptious
Scrumdiddlyumptious
Answer: B
Question 206
Given:
11. public class ItemTest {
12. private final mt id;
13. public ItemTest(int id) { this.id = id; }
14. public void updateId(int newId) { id = newId; }
15.
16. public static void main(String[] args) {
17. ItemTest fa = new ItemTest(42);
18. fa.updateId(69);
19. System.out.println(fa.id);
20. }
21. }
What is the result?
A. Compilation fails.
B. An exception is thrown at runtime.
C. The attribute id in the Item object remains unchanged.
D. The attribute id in the Item object is modified to the new value.
E. A new Item object is created with the preferred value in the id
attribute.
Answer: A
Question 207
Click the Exhibit button.
10. class Inner {
11. private int x;
12. public void setX( int x) { this.x = x; }
13. public int getX() { return x; }
14. }
15.
16. class Outer {
17. private Inner y;
18. public void setY( Inner y) { this.y = y; }
19. public Inner getY() { return y; }
20. }
21.
22. public class Gamma {
23. public static void main( String[] args) {
24. Outer o = new Outer();
25. Inner i = new Inner();
26.int n=10;
27. i.setX(n);
28. o.setY(i);
29. // insert code here
30. System.out.println( o.getY().getX());
31. }
32. }
Which three code fragments, added individually at line 29, produce the
output 100? (Choose three.)
A. n = 100;
B. i.setX( 100);
C. o.getY().setX( 100);
D. i = new Inner(); i.setX( 100);
E. o.setY( i); i = new Inner(); i.setX( 100);
F. i = new Inner(); i.setX( 100); o.setY( i);
Answer: BCF
Question 208
Click the Exhibit button.
10. class Foo {
11. private int x;
12.publicFoo(intx) {this.x=x; }
13. public void setX( int x) { this.x = x; }
14. public int getX() { return x; }
15. }
16.
17. public class Gamma {
18.
19. static Foo fooBar( Foo foo) {
20. foo = new Foo( 100);
21. return foo;
22. }
23.
24. public static void main( String[] args) {
25. Foo foo = new Foo( 300);
26. System.out.print( foo.getX() + “-“);
27.
28. Foo fooFoo = fooBar( foo);
29. System.out.print( foo.getX() + “-“);
30. System.out.print( fooFoo.getX() + “-“);
31.
32. foo = fooBar( fooFoo);
33. System.out.print( foo.getX() + “-“);
34. System.out.prmt( fooFoo.getX());
35. }
36. }
What is the output of this program?
A. 300-100-100-100-100
B. 300-300-100-100-100
C. 300-300-300-100-100
D. 300-300-300-300-100
Answer: B
Question 209
Given:
11. public void genNumbers() {
12. ArrayList numbers = new ArrayList();
13. for (int i=0; i<10; i++) {
14. int value = i * ((int) Math.random());
15. Integer intObj = new Integer(value);
16. numbers.add(intObj);
17. }
18. System.out.println(numbers);
19. }
Which line of code marks the earliest point that an object referenced
by intObj becomes a candidate for garbage collection?
A. Line 16
B. Line 17
C. Line 18
D. Line 19
E. The object is NOT a candidate for garbage collection.
Answer: D
Question 210
Given:
11. rbo = new ReallyBigObject();
12. // more code here
13. rbo = null;
14. /* insert code here */
Which statement should be placed at line 14 to suggest that the virtual
machine expend effort toward recycling the memory used by the
object rbo?
A. System.gc();
B. Runtime.gc();
C. System.freeMemory();
D. Runtime.getRuntime().growHeap();
E. Runtime.getRuntime().freeMemory();
Answer: A
Question 211
Given:
11. class Snoochy {
12. Boochybooch;
13. public Snoochy() { booch = new Boochy(this); }
14. }
15.
16. class Boochy {
17. Snoochy snooch;
18. public Boochy(Snoochy s) { snooch = s; }
19. }
And the statements:
21. public static void main(String[] args) {
22. Snoochy snoog = new Snoochy();
23. snoog = null;
24. // more code here
25. }
Which statement is true about the objects referenced by snoog,
snooch, and booch immediately after line 23 executes?
A. None of these objects are eligible for garbage collection.
B. Only the object referenced by booch is eligible for garbage
collection.
C. Only the object referenced by snoog is eligible for garbage
collection.
D. Only the object referenced by snooch is eligible for garbage
collection.
E. The objects referenced by snooch and booch are eligible for garbage
collection.
Answer: E
Question 212
Given:
1. public class GC {
2. private Object o;
3. private void doSomethingElse(Object obj) { o = obj; }
4. public void doSomething() {
5. Object o = new Object();
6. doSomethingElse(o);
7. o = new Object();
8. doSomethingElse(null);
9.o=null;
10. }
11. }
When the doSomething method is called, after which line does the
Object created in line 5 become available for garbage collection?
A. Line 5
B. Line 6
C. Line 7
D. Line 8
E. Line 9
F. Line 10
Answer: D
Question 213
Which two are true? (Choose two.)
A. A finalizer may NOT be invoked explicitly.
B. The finalize method declared in class Object takes no action.
C. super.finalize() is called implicitly by any overriding finalize method.
D. The finalize method for a given object will be called no more than
once by the garbage collector.
E. The order in which finalize will be called on two objects is based on
the order in which the two objects became finalizable.
Answer: BD
Question 214
A class games.cards.Poker is correctly defined in the jar file Poker.jar.
A user wants to execute the main method of Poker on a UNIX system
using the command:
java games.cards.Poker
What allows the user to do this?
A. put Poker.jar in directory /stuff/java, and set the CLASSPATH to
include /stuff/java
B. put Poker.jar in directory /stuff/java, and set the CLASSPATH to
include /stuff/java/*.jar
C. Put Poker.jar in directory /stuff/java, and set the CLASSPATH to
include /stuff/java/Poker.jar
D. put Poker.jar in directory /stuff/java/games/cards, and set the
CLASSPATH to include /stuff/java
E. put Poker.jar in directory /stuff/java/games/cards, and set the
CLASSPATH to include /stuffijava/*.jar
F. put Poker.jar in directory /stuff/java/games/cards, and set the
CLASSPATH to include /stuff/java/Poker.jar
Answer: C
Question 215
Click the Exhibit button.
Given the fully-qualified class names:
com.foo.bar.Dog
com.foo.bar.blatz.Book
com.bar.Car
com.bar.blatz.Sun
Which graph represents the correct directory structure for a JAR file
from which those classes can be used by the compiler and JYM?
A. Jar A
B. Jar B
C. Jar C
D. Jar D
E. Jar E
Answer: A
Question 216
A developer is creating a class Book that needs to access class Paper.
The Paper class is deployed in a JAR named myLib.jar. Which three,
taken independently, will allow the developer to use the Paper class
while compiling the Book class? (Choose three.)
A. The JAR file is located at $JAVA_HOME/jre/classes/myLib.jar.
B. The JAR file is located at $JAVA_HOME/jre/lib/ext/myLib.jar.
C. The JAR file is located at /foo/myLib.jar and a classpath
environment variable is set that includes /foo/myLib.jar/Paper.class.
D. The JAR file is located at /foo/myLib.jar and a classpath
environment variable is set that includes /foo/myLib.jar.
E. The JAR file is located at /foo/myLib.jar and the Book class is
compiled using javac -cp /foo/myLib.jar/Paper Book.java.
F. The JAR file is located at /foo/myLib.jar and the Book class is
compiled using javac -d /foo/myLib.jar Book.java.
G. The JAR file is located at /foo/myLib.jar and the Book class is
compiled using javac -classpath /foo/myLib.jar Book.java.
Answer: BDG
Question 217
Given:
1. package com.company.application;
2.
3. public class MainClass {
4. public static void main(String[] args) { }
5. }
And MainClass exists in the /apps/com/company/application directory.
Assume the CLASSPATH environment variable is set to “.“ (current
directory). Which two java commands entered at the command line
will run MainClass? (Choose two.)
A. java MainClass if run from the /apps directory
B. java com.company.application.MainClass if run from the /apps
directory
C. java -classpath /apps com.company.application.MainClass if run
from any directory
D. java -classpath . MainClass if run from the
/apps/com/company/application directory
E. java -classpath /apps/com/company/application:. MainClass if run
from the /apps directory
F. java com.company.application.MainClass if run from the
/apps/com/company/application directory
Answer: BC
Question 218
A UNIX user named Bob wants to replace his chess program with a
new one, but he is hot sure where the old one is installed. Bob is
currently able to run a Java chess program starting from his home
directory /home/bob using the command:
java -classpath /test:/home/bob/downloads/* .jar games.Chess
Bob’s CLASSPATH is set (at login time) to:
/usr/lib:/home/bob/classes:/opt/java/lib:/opt/java/lib/* .jar
What is a possible location for the Chess.class file?
A. /test/Chess.class
B. /home/bob/Chess.class
C. /test/games/Chess.class
D. /usr/lib/games/Chess.class
E. /home/bob/games/Chess.class
F. inside jarfile /opt/java/lib/Games.jar (with a correct manifest)
G. inside jarfile /home/bob/downloads/Games.jar (with a correct
manifest)
Answer: C
Question 219
Given:
11. public static void test(String str) {
12. if(str == null | str.lellgth() == 0) {
13. System.out.println(”String is empty”);
14. } else {
15. System.out.println(”String is not empty”);
16. }
17. }
And the invocation:
31. test(llull);
What is the result?
A. Au exception is thrown at runtime.
B. “String is empty” is printed to output.
C. Compilation fails because of au error in line 12.
D. “String is not empty” is printed to output.
Answer: A
Question 220
Given:
11. public static void test(String str) {
12. int check = 4;
13. if (check = str.length()) {
14. System.out.print(str.charAt(check -= 1) +“, “);
15. } else {
16. System.out.print(str.charAt(0) + “, “);
17. }
18. }
and the invocation:
21. test(”four”);
22. test(”tee”);
23. test(”to”);
What is the result?
A. r, t, t,
B. r, e, o,
C. Compilation fails.
D. An exception is thrown at runtime.
Answer: C
Question 221
Given:
10. public class MyClass {
11.
12. public Integer startingI;
13. public void methodA() {
14. Integer i = new Integer(25);
15. startingI = i;
16. methodB(i);
17. }
18. private void methodB(Integer i2) {
19. i2 = i2.intValue();
20.
21. }
22. }
If methodA is invoked, which two are true at line 20? (Choose two.)
A. i2 == startingI returns true.
B. i2 == startingI returns false.
C. i2.equals(startingI) returns true.
D. i2.equals(startingI) returns false.
Answer: BC
Question 222
222. Given:
11. class Cup { }
12. class PoisonCup extends Cup { }
21. public void takeCup(Cup c) {
22. if(c instanceof PoisonCup) {
23. System.out.println(”Inconceivable!”);
24. } else if(c instanceof Cup) {
25. System.out.println(”Dizzying intellect!”);
26. } else {
27. System.exit(0);
28. }
29. }
And the execution of the statements:
Cup cup = new PoisonCup();
takeCup(cup);
What is the output?
A. Inconceivable!
B. Dizzying intellect!
C. The code runs with no output.
D. An exception is thrown at runtime.
E. Compilation fails because of an error in line 22.
Answer: A
Question 223
Given:
11. String[] elements = { “for”, “tea”, “too” };
12. String first = (elements.length > 0)? elements[0] null;
What is the result?
A. Compilation fails.
B. An exception is thrown at runtime.
C. The variable first is set to null.
D. The variable first is set to elements[0].
Answer: D
Question 224
Given:
42. public class ClassA {
43. public int getValue() {
44.int value=0;
45. boolean setting = true;
46. String title=”Hello”;
47. if (value || (setting && title == “Hello”)) { return 1; }
48. if (value == 1 & title.equals(”Hello”)) { return 2; }
49. }
50. }
And:
70. ClassA a = new ClassA();
71. a.getValue();
What is the result?
A. 1
B. 2
C. Compilation fails.
D. The code runs with no output.
E. An exception is thrown at runtime.
Answer: C


**********************************

Sun's certification program in Java technology is an industry recognized, worldwide program that focuses on critical job roles in software application development and enterprise architecture. Since these certifications focus on the technology, the knowledge and skills learned while preparing for Sun's certifications are transportable from one company to another.
Sun's philosophy is that certification is central to the learning process as it provides validation of skill sets for specific job roles. Sun certification also offers a natural progression to support your career goals.
First, by becoming a Sun Certified Associate Sun verifies that you have a base set of knowledge that enables entry into a career in application development or software project management using Java technology.
Second, we train developers on a foundational set of skills, which can then be validated by becoming a Sun Certified Programmer.
Afterwards, you can pursue advanced or specialty training and certifications that help enable career growth into more specific job roles making you more valuable to an organization.
Sun offers the following Java technology professional certifications:

- Sun Certified Java Associate (SCJA)
- Sun Certified Java Programmer (SCJP)
- Sun Certified Java Developer (SCJD)
- Sun Certified Web Component Developer (SCWCD)
- Sun Certified Business Component Developer (SCBCD)
- Sun Certified Developer For Java Web Services (SCDJWS)
- Sun Certified Mobile Application Developer (SCMAD)
- Sun Certified Enterprise Architect (SCEA)
Please note that the goal of Sun certification is to test on a particular job role. Thus, to prepare for a certification exam we recommend Sun training and six to twelve months of actual job role experience. Sun does not claim that by taking courses you are guaranteed to pass the certification exams, however we do state that Sun training is an important component in certification preparation. Please see training preparation methods corresponding with each certification listed above.







$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$



Sun Certified Java Programmer (SCJP) Overview


Java Questions

1. Can a main() method of class be invoked in another class?
2. What is the difference between java command line arguments and C command line arguments?
3. What is the difference between == & .equals
4. What is the difference between abstract class & Interface.
5. What is singleton class & it's implementation.
6. Use of static,final variable
7. Examples of final class
8. Difference between Event propagation & Event delegation
9. Difference between Unicast & Multicast model
10. What is a java bean
11. What is synchronized keyword used for.
12. What are the restrictions of an applet & how to make the applet access the local machines resources.
13. What is reflect package used for & the methods of it.
14. What is serialization used for
15. Can methods be overloaded based on the return types ?
16. Why do we need a finalze() method when Garbage Collection is there ?
17. Difference between AWT and Swing compenents ?
18. Is there any heavy weight component in Swings ?
19. Can the Swing application if you upload in net, be compatible with your browser?
20. What should you do get your browser compatible with swing components?
21. What are the methods in Applet ?
22. When is init(),start() called ?
23. When you navigate from one applet to another what are the methods called?
24. What is the difference between Trusted and Untrusted Applet ?
25. What is Exception ?
26. What are the ways you can handle exception ?
27. When is try,catch block used ?
28. What is finally method in Exceptions ?
29. What are the types of access modifiers ?
30. What is protected and friendly ?
31. What are the other modifiers ?
32. Is synchronised modifier ?
33. What is meant by polymorphism ?
34. What is inheritance ?
35. What is method Overloading ? What is this in OOPS ?
36. What is method Overriding ? What is it in OOPS ?
37. Does java support multi dimensional arrays ?
38. Is multiple inheritance used in Java ?
39. How do you send a message to the browser in JavaScript ?
40. Does javascript support multidimensional arrays ?
41. Is there any tool in java that can create reports ?
42. What is meant by Java ?
43. What is meant by a class ?
44. What is meant by a method ?
45. What are the OOPS concepts in Java ?
46. What is meant by encapsulation ? Explain with an example
47. What is meant by inheritance ? Explain with an example
48. What is meant by polymorphism ? Explain with an example
49. Is multiple inheritance allowed in Java ? Why ?
50. What is meant by Java interpreter ?
51. What is meant by JVM ?
52. What is a compilation unit ?
53. What is meant by identifiers ?
54. What are the different types of modifiers ?
55. What are the access modifiers in Java ?
56. What are the primitive data types in Java ?
57. What is meant by a wrapper class ?
58. What is meant by static variable and static method ?
59. What is meant by Garbage collection ?
60. What is meant by abstract class
61. What is meant by final class, methods and variables ?
62. What is meant by interface ?
63. What is meant by a resource leak ?
64. What is the difference between interface and abstract class ?
65. What is the difference between public private, protected and static
66. What is meant by method overloading ?
67. What is meant by method overriding ?
68. What is singleton class ?
69. What is the difference between an array and a vector ?
70. What is meant by constructor ?
71. What is meant by casting ?
72. What is the difference between final, finally and finalize ?
73. What is meant by packages ?
74. What are all the packages ?
75. Name 2 calsses you have used ?
76. Name 2 classes that can store arbitrary number of objects ?
77. What is the difference between java.applet.* and java.applet.Applet ?
78. What is a default package ?
79. What is meant by a super class and how can you call a super class ?
80. What is anonymous class ?
81. Name interfaces without a method ?
82. What is the use of an interface ?
83. What is a serializable interface ?
84. How to prevent field from serialization ?
85. What is meant by exception ?
86. How can you avoid the runtime exception ?
87. What is the difference between throw and throws ?
88. What is the use of finally ?
89. Can multiple catch statements be used in exceptions ?
90. Is it possible to write a try within a try statement ?
91. What is the method to find if the object exited or not ?
92. What is meant by a Thread ?
93. What is meant by multi-threading ?
94. What is the 2 way of creating a thread ? Which is the best way and why?
95. What is the method to find if a thread is active or not ?
96. What are the thread-to-thread communcation ?
97. What is the difference between sleep and suspend ?
98. Can thread become a member of another thread ?
99. What is meant by deadlock ?
100. How can you avoid a deadlock ?
101. What are the three typs of priority ?
102. What is the use of synchronizations ?
103. Garbage collector thread belongs to which priority ?
104. What is meant by time-slicing ?
105. What is the use of 'this' ?
106. How can you find the length and capacity of a string buffer ?
107. How to compare two strings ?
108. What are the interfaces defined by Java.lang ?
109. What is the purpose of run-time class and system class
110. What is meant by Stream and Types ?
111. What is the method used to clear the buffer ?
112. What is meant by Stream Tokenizer ?
113. What is serialization and de-serialisation ?
114. What is meant by Applet ?
115. How to find the host from which the Applet has originated ?
116. What is the life cycle of an Applet ?
117. How do you load an HTML page from an Applet ?
118. What is meant by Applet Stub Interface ?
119. What is meant by getCodeBase and getDocumentBase method ?
120. How can you call an applet from a HTML file
121. What is meant by Applet Flickering ?
122. What is the use of parameter tag ?
123. What is audio clip Interface and what are all the methods in it ?
124. What is the difference between getAppletInfo and getParameterInfo ?
125. How to communicate between applet and an applet ?
126. What is meant by event handling ?
127. What are all the listeners in java and explain ?
128. What is meant by an adapter class ?
129. What are the types of mouse event listeners ?
130. What are the types of methods in mouse listeners ?
131. What is the difference between panel and frame ?
132. What is the default layout of the panel and frame ?
133. What is meant by controls and types ?
134. What is the difference between a scroll bar and a scroll panel.
135. What is the difference between list and choice ?
136. How to place a component on Windows ?
137. What are the different types of Layouts ?
138. What is meant by CardLayout ?
139. What is the difference between GridLayout and GridBagLayout
140. What is the difference between menuitem and checkboxmenu item.
141. What is meant by vector class, dictionary class , hash table class,and property class ?
142. Which class has no duplicate elements ?
143. What is resource bundle ?
144. What is an enumeration class ?
145. What is meant by Swing ?
146. What is the difference between AWT and Swing ?
147. What is the difference between an applet and a Japplet
148. What are all the components used in Swing ?
149. What is meant by tab pans ?
150. What is the use of JTree ?
151. How can you add and remove nodes in Jtree.
152. What is the method to expand and collapse nodes in a Jtree
153. What is the use of JTable ?
154. What is meant by JFC ?
155. What is the class in Swing to change the appearance of the Frame in Runtime.
156. How to reduce flicking in animation ?
157. What is meant by Javabeans ?
158. What is JAR file ?
159. What is meant by manifest files ?
160. What is Introspection ?
161. What are the steps involved to create a bean ?
162. Say any two properties in Beans ?
163. What is persistence ?
164. What is the use of beaninfo ?
165. What are the interfaces you used in Beans ?
166. What are the classes you used in Beans ?
167. What is the diffrence between an Abstract class and Interface
168. What is user defined exception ?
169. What do you know about the garbate collector ?
170. What is the difference between C++ & Java ?
171. How do you communicate in between Applets & Servlets ?
172. What is the use of Servlets ?
173. In an HTML form I have a Button which makes us to open another page in 15 seconds. How will do you that ?
174. What is the difference between Process and Threads ?
175. How will you initialize an Applet ?
176. What is the order of method invocation in an Applet ?
177. When is update method called ?
178. How will you communicate between two Applets ?
179. Have you ever used HashTable and Dictionary ?
180. What are statements in JAVA ?
181. What is JAR file ?
182. What is JNI ?
183. What is the base class for all swing components ?
184. What is JFC ?
185. What is Difference between AWT and Swing ?
186. Considering notepad/IE or any other thing as process, What will Happen if you start notepad or IE 3 times? Where 3 processes are started or 3 threads are started ?
187. How does thread synchronization occurs inside a monitor ?
188. How will you call an Applet using a Java Script function ?
189. Is there any tag in HTML to upload and download files ?
190. Why do you Canvas ?
191. How can you push data from an Applet to Servlet ?
192. What are the benefits of Swing over AWT ?
193. Where the CardLayout is used ?
194. What is the Layout for ToolBar ?
195. What is the difference between Grid and GridbagLayout ?
196. How will you add panel to a Frame ?
197. What is the corresponding Layout for Card in Swing ?
198. What is light weight component ?
199. What is bean ? Where it can be used ?
200. What is difference in between Java Class and Bean ?
201. What is the mapping mechanism used by Java to identify IDL language ?
202. Diff between Application and Applet ?
203. What is serializable Interface ?
204. What is the difference between CGI and Servlet ?
205. What is the use of Interface ?
206. Why Java is not fully objective oriented ?
207. Why does not support multiple Inheritance ?
208. What it the root class for all Java classes ?
209. What is polymorphism ?
210. Suppose If we have variable ' I ' in run method, If I can create one or More thread each thread will occupy a separate copy or same variable will be shared ?
211. What is Constructor and Virtual function? Can we call Virtual
212. Funciton in a constructor ?
213. Why we use OOPS concepts? What is its advantage ?
214. What is the difference in between C++ and Java ? can u explain in detail?
215. What is the exact difference in between Unicast and Multicast object ? Where we will use ?
216. How do you sing an Applet ?
217. In a Container there are 5 components. I want to display the all the components names, how will you do that one ?
218. Why there are some null interface in java ? What does it mean ?
219. Give me some null interfaces in JAVA ?
220. Tell me the latest versions in JAVA related areas ?
221. What is meant by class loader ? How many types are there? When will we use them ?
222. What is meant by flickering ?
223. What is meant by cookies ? Explain ?
224. Problem faced in your earlier project
225. How OOPS concept is achieved in Java
226. Features for using Java
227. How does Java 2.0 differ from Java 1.0
228. Public static void main - Explain
229. What are command line arguments
230. Explain about the three-tier model
231. Difference between String & StringBuffer
232. Wrapper class. Is String a Wrapper Class
233. What are the restriction for static method Purpose of the file class
234. Default modifier in Interface
235. Difference between Interface & Abstract class
236. Can abstract be declared as Final
237. Can we declare variables inside a method as Final Variables
238. What is the package concept and use of package
239. How can a dead thread be started
240. Difference between Applet & Application
241. Life cycle of the Applet
242. Can Applet have constructors
243. Differeence between canvas class & graphics class
244. Explain about Superclass & subclass
245. What is AppletStub
246. Explain Stream Tokenizer
247. What is the difference between two types of threads
248. Checked & Unchecked exception
249. Use of throws exception
250. What is finally in exception handling Vector class
251. What will happen to the Exception object after exception handling
252. Two types of multi-tasking
253. Two ways to create the thread
254. Synchronization
255. I/O Filter
256. Can applet in different page communicate with each other
257. Why Java is not 100 % pure OOPS ? ( EcomServer )
258. When we will use an Interface and Abstract class ?
259. How to communicate 2 threads each other ?




Best Interview HR Question

Table of Contents

General Guidelines in Answering Interview Questions....................................................... 3
Q1 Tell me about yourself.......................................................................................... 5
Q2 What are your greatest strengths?...................................................................... 6
Q3 What are your greatest weaknesses?................................................................. 6
Q4 Tell me about something you did – or failed to do – that you now feel a little ashamed of. 7
Q5 Why are you leaving (or did you leave) this position?.......................................... 8
Q6 The “Silent Treatment”......................................................................................... 9
Q7 Why should I hire you?......................................................................................... 9
Q8 Aren’t you overqualified for this position?........................................................... 10
Q9 Where do you see yourself five years from now?.............................................. 11
Q10 Describe your ideal company, location and job................................................. 12
Q11 Why do you want to work at our company?....................................................... 12
Q12 What are your career options right now?........................................................... 12
Q13 Why have you been out of work so long?.......................................................... 13
Q14 Tell me honestly about the strong points and weak points of your boss (company, management team, etc.)…................................................................................................................. 13
Q15 What good books have you read lately?............................................................ 14
Q16 Tell me about a situation when your work was criticized................................... 14
Q17 What are your outside interest?......................................................................... 15
Q18 The “Fatal Flaw” question................................................................................... 15
Q19 How do you feel about reporting to a younger person (minority, woman, etc)? 16
Q20 On confidential matters….................................................................................. 16
Q21 Would you lie for the company?......................................................................... 17
Q22 Looking back, what would you do differently in your life?................................... 17
Q23 Could you have done better in your last job?..................................................... 18
Q24 Can you work under pressure?.......................................................................... 18
Q25 What makes you angry?.................................................................................... 18
Q26 Why aren’t you earning more money at this stage of your career?................... 19
Q27 Who has inspired you in your life and why?....................................................... 19
Q28 What was the toughest decision you ever had to make?.................................. 20
Q29 Tell me about the most boring job you’ve ever had............................................ 20
Q30 Have you been absent from work more than a few days in any previous position? 20
Q31 What changes would you make if you came on board?.................................... 21
Q32 I’m concerned that you don’t have as much experience as we’d like in…........ 21
Q33 How do you feel about working nights and weekends?..................................... 22
Q34 Are you willing to relocate or travel?................................................................... 23
Q35 Do you have the stomach to fire people? Have you had experience firing many people? 23
Q36 Why have you had so many jobs?..................................................................... 24
Q37 What do you see as the proper role/mission of… …a good (job title you’re seeking); …a good manager; …an executive in serving the community; …a leading company in our industry; etc. 25
Q38 What would you say to your boss if he’s crazy about an idea, but you think it stinks? 25
Q39 How could you have improved your career progress?...................................... 26
Q40 What would you do if a fellow executive on your own corporate level wasn’t pulling his/her weight…and this was hurting your department?............................................................................ 26
Q41 You’ve been with your firm a long time. Won’t it be hard switching to a new company? 27
Q42 May I contact your present employer for a reference?....................................... 27
Q43 Give me an example of your creativity (analytical skill…managing ability, etc.) 28
Q44 Where could you use some improvement?....................................................... 28
Q45 What do you worry about?................................................................................. 28
Q46 How many hours a week do you normally work?............................................... 28
Q47 What’s the most difficult part of being a (job title)?............................................ 29
Q48 The “Hypothetical Problem”................................................................................ 29
Q49 What was the toughest challenge you’ve ever faced?....................................... 29
Q50 Have you consider starting your own business?............................................... 30
Q51 What are your goals?......................................................................................... 31
Q52 What do you for when you hire people?............................................................. 31
Q53 Sell me this stapler…(this pencil…this clock…or some other object on interviewer’s desk). 31
Q54 “The Salary Question” – How much money do you want?................................ 33
Q55 The Illegal Question............................................................................................ 33
Q56 The “Secret” Illegal Question.............................................................................. 34
Q57 What was the toughest part of your last job?..................................................... 35
Q58 How do you define success…and how do you measure up to your own definition?. 35
Q59 “The Opinion Question” – What do you think about …Abortion…The President…The Death Penalty…(or any other controversial subject)?....................................................................... 36
Q60 If you won $10 million lottery, would you still work?........................................... 36
Q61 Looking back on your last position, have you done your best work?................. 37
Q62 Why should I hire you from the outside when I could promote someone from within? 37
Q63 Tell me something negative you’ve heard about our company…...................... 38
Q64 On a scale of one to ten, rate me as an interviewer.......................................... 38

General Guidelinesin Answering Interview Questions
Everyone is nervous on interviews. If you simply allow yourself to feel nervous, you'll do much better. Remember also that it's difficult for the interviewer as well.
In general, be upbeat and positive. Never be negative.
Rehearse your answers and time them. Never talk for more than 2 minutes straight.
Don't try to memorize answers word for word. Use the answers shown here as a guide only, and don't be afraid to include your own thoughts and words. To help you remember key concepts, jot down and review a few key words for each answer. Rehearse your answers frequently, and they will come to you naturally in interviews.
As you will read in the accompanying report, the single most important strategy in interviewing, as in all phases of your job search, is what we call: "The Greatest Executive Job Finding Secret." And that is...
Find out what people want, than show them how you can help them get it.
Find out what an employer wants most in his or her ideal candidate, then show how you meet those qualifications.
In other words, you must match your abilities, with the needs of the employer. You must sell what the buyer is buying. To do that, before you know what to emphasize in your answers, you must find out what the buyer is buying... what he is looking for. And the best way to do that is to ask a few questions yourself.
You will see how to bring this off skillfully as you read the first two questions of this report. But regardless of how you accomplish it, you must remember this strategy above all: before blurting out your qualifications, you must get some idea of what the employer wants most. Once you know what he wants, you can then present your qualifications as the perfect “key” that fits the “lock” of that position.
· Other important interview strategies:
· Turn weaknesses into strengths (You'll see how to do this in a few moments.)
· Think before you answer. A pause to collect your thoughts is a hallmark of a thoughtful person.
As a daily exercise, practice being more optimistic. For example, try putting a positive spin on events and situations you would normally regard as negative. This is not meant to turn you into a Pollyanna, but to sharpen your selling skills. The best salespeople, as well as the best liked interview candidates, come off as being naturally optimistic, "can do" people. You will dramatically raise your level of attractiveness by daily practicing to be more optimistic.
Be honest...never lie.
Keep an interview diary. Right after each interview note what you did right, what could have gone a little better, and what steps you should take next with this contact. Then take those steps. Don't be like the 95% of humanity who say they will follow up on something, but never do.
About the 64 questions...
You might feel that the answers to the following questions are “canned”, and that they will seldom match up with the exact way you are asked the questions in actual interviews. The questions and answers are designed to be as specific and realistic as possible. But no preparation can anticipate thousands of possible variations on these questions. What's important is that you thoroughly familiarize yourself with the main strategies behind each answer. And it will be invaluable to you if you commit to memory a few key words that let you instantly call to mind your best answer to the various questions. If you do this, and follow the principles of successful interviewing presented here, you're going to do very well.
Good luck...and good job-hunting!
Question 1 Tell me about yourself.
TRAPS: Beware, about 80% of all interviews begin with this “innocent” question. Many candidates, unprepared for the question, skewer themselves by rambling, recapping their life story, delving into ancient work history or personal matters.
BEST ANSWER: Start with the present and tell why you are well qualified for the position. Remember that the key to all successful interviewing is to match your qualifications to what the interviewer is looking for. In other words you must sell what the buyer is buying. This is the single most important strategy in job hunting.
So, before you answer this or any question it's imperative that you try to uncover your interviewer's greatest need, want, problem or goal.
To do so, make you take these two steps:
1. Do all the homework you can before the interview to uncover this person's wants and needs (not the generalized needs of the industry or company)
2. As early as you can in the interview, ask for a more complete description of what the position entails. You might say: “I have a number of accomplishments I'd like to tell you about, but I want to make the best use of our time together and talk directly to your needs. To help me do, that, could you tell me more about the most important priorities of this position? All I know is what I (heard from the recruiter, read in the classified ad, etc.)”
Then, ALWAYS follow-up with a second and possibly, third question, to draw out his needs even more. Surprisingly, it's usually this second or third question that unearths what the interviewer is most looking for.
You might ask simply, "And in addition to that?..." or, "Is there anything else you see as essential to success in this position?:
This process will not feel easy or natural at first, because it is easier simply to answer questions, but only if you uncover the employer's wants and needs will your answers make the most sense. Practice asking these key questions before giving your answers, the process will feel more natural and you will be light years ahead of the other job candidates you're competing with.
After uncovering what the employer is looking for, describe why the needs of this job bear striking parallels to tasks you've succeeded at before. Be sure to illustrate with specific examples of your responsibilities and especially your achievements, all of which are geared to present yourself as a perfect match for the needs he has just described.
Question 2 What are your greatest strengths?
TRAPS: This question seems like a softball lob, but be prepared. You don't want to come across as egotistical or arrogant. Neither is this a time to be humble.
BEST ANSWER: You know that your key strategy is to first uncover your interviewer's greatest wants and needs before you answer questions. And from Question 1, you know how to do this.
Prior to any interview, you should have a list mentally prepared of your greatest strengths. You should also have, a specific example or two, which illustrates each strength, an example chosen from your most recent and most impressive achievements.
You should, have this list of your greatest strengths and corresponding examples from your achievements so well committed to memory that you can recite them cold after being shaken awake at 2:30AM.
Then, once you uncover your interviewer's greatest wants and needs, you can choose those achievements from your list that best match up.
As a general guideline, the 10 most desirable traits that all employers love to see in their employees are:
1. A proven track record as an achiever...especially if your achievements match up with the employer's greatest wants and needs.
2. Intelligence...management "savvy".
3. Honesty...integrity...a decent human being.
4. Good fit with corporate culture...someone to feel comfortable with...a team player who meshes well with interviewer's team.
5. Likeability...positive attitude...sense of humor.
6. Good communication skills.
7. Dedication...willingness to walk the extra mile to achieve excellence.
8. Definiteness of purpose...clear goals.
9. Enthusiasm...high level of motivation.
10. Confident...healthy...a leader.
Question 3 What are your greatest weaknesses?
TRAPS: Beware - this is an eliminator question, designed to shorten the candidate list. Any admission of a weakness or fault will earn you an “A” for honesty, but an “F” for the interview.
PASSABLE ANSWER: Disguise a strength as a weakness.
Example: “I sometimes push my people too hard. I like to work with a sense of urgency and everyone is not always on the same wavelength.”
Drawback: This strategy is better than admitting a flaw, but it's so widely used, it is transparent to any experienced interviewer.
BEST ANSWER: (and another reason it's so important to get a thorough description of your interviewer's needs before you answer questions): Assure the interviewer that you can think of nothing that would stand in the way of your performing in this position with excellence. Then, quickly review you strongest qualifications.
Example: “Nobody's perfect, but based on what you've told me about this position, I believe I' d make an outstanding match. I know that when I hire people, I look for two things most of all. Do they have the qualifications to do the job well, and the motivation to do it well? Everything in my background shows I have both the qualifications and a strong desire to achieve excellence in whatever I take on. So I can say in all honesty that I see nothing that would cause you even a small concern about my ability or my strong desire to perform this job with excellence.”
Alternate strategy (if you don't yet know enough about the position to talk about such a perfect fit): Instead of confessing a weakness, describe what you like most and like least, making sure that what you like most matches up with the most important qualification for success in the position, and what you like least is not essential.
Example: Let's say you're applying for a teaching position. “If given a choice, I like to spend as much time as possible in front of my prospects selling, as opposed to shuffling paperwork back at the office. Of course, I long ago learned the importance of filing paperwork properly, and I do it conscientiously. But what I really love to do is sell (if your interviewer were a sales manager, this should be music to his ears.)
Question 4 Tell me about something you did – or failed to do – that you now feel a little ashamed of.
TRAPS: There are some questions your interviewer has no business asking, and this is one. But while you may feel like answering, “none of your business,” naturally you can’t. Some interviewers ask this question on the chance you admit to something, but if not, at least they’ll see how you think on your feet.
Some unprepared candidates, flustered by this question, unburden themselves of guilt from their personal life or career, perhaps expressing regrets regarding a parent, spouse, child, etc. All such answers can be disastrous.
BEST ANSWER: As with faults and weaknesses, never confess a regret. But don’t seem as if you’re stonewalling either.
Best strategy: Say you harbor no regrets, then add a principle or habit you practice regularly for healthy human relations.
Example: Pause for reflection, as if the question never occurred to you. Then say, “You know, I really can’t think of anything.” (Pause again, then add): “I would add that as a general management principle, I’ve found that the best way to avoid regrets is to avoid causing them in the first place. I practice one habit that helps me a great deal in this regard. At the end of each day, I mentally review the day’s events and conversations to take a second look at the people and developments I’m involved with and do a doublecheck of what they’re likely to be feeling. Sometimes I’ll see things that do need more follow-up, whether a pat on the back, or maybe a five minute chat in someone’s office to make sure we’re clear on things…whatever.”
“I also like to make each person feel like a member of an elite team, like the Boston Celtics or LA Lakers in their prime. I’ve found that if you let each team member know you expect excellence in their performance…if you work hard to set an example yourself…and if you let people know you appreciate and respect their feelings, you wind up with a highly motivated group, a team that’s having fun at work because they’re striving for excellence rather than brooding over slights or regrets.”
Question 5 Why are you leaving (or did you leave) this position?
TRAPS: Never badmouth your previous industry, company, board, boss, staff, employees or customers. This rule is inviolable: never be negative. Any mud you hurl will only soil your suit.
Especially avoid words like “personality clash”, “didn’t get along”, or others which cast a shadow on your competence, integrity, or temperament.
BEST ANSWER:
(If you have a job presently)If you’re not yet 100% committed to leaving your present post, don’t be afraid to say so. Since you have a job, you are in a stronger position than someone who does not. But don’t be coy either. State honestly what you’d be hoping to find in a new spot. Of course, as stated often before, you answer will all the stronger if you have already uncovered what this position is all about and you match your desires to it.
(If you do not presently have a job.)Never lie about having been fired. It’s unethical – and too easily checked. But do try to deflect the reason from you personally. If your firing was the result of a takeover, merger, division wide layoff, etc., so much the better.
But you should also do something totally unnatural that will demonstrate consummate professionalism. Even if it hurts , describe your own firing – candidly, succinctly and without a trace of bitterness – from the company’s point-of-view, indicating that you could understand why it happened and you might have made the same decision yourself.
Your stature will rise immensely and, most important of all, you will show you are healed from the wounds inflicted by the firing. You will enhance your image as first-class management material and stand head and shoulders above the legions of firing victims who, at the slightest provocation, zip open their shirts to expose their battle scars and decry the unfairness of it all.
For all prior positions:Make sure you’ve prepared a brief reason for leaving. Best reasons: more money, opportunity, responsibility or growth.
Question 6 The “Silent Treatment”
TRAPS: Beware – if you are unprepared for this question, you will probably not handle it right and possibly blow the interview. Thank goodness most interviewers don’t employ it. It’s normally used by those determined to see how you respond under stress. Here’s how it works:
You answer an interviewer’s question and then, instead of asking another, he just stares at you in a deafening silence.
You wait, growing a bit uneasy, and there he sits, silent as Mt. Rushmore, as if he doesn’t believe what you’ve just said, or perhaps making you feel that you’ve unwittingly violated some cardinal rule of interview etiquette.
When you get this silent treatment after answering a particularly difficult question , such as “tell me about your weaknesses”, its intimidating effect can be most disquieting, even to polished job hunters.
Most unprepared candidates rush in to fill the void of silence, viewing prolonged, uncomfortable silences as an invitation to clear up the previous answer which has obviously caused some problem. And that’s what they do – ramble on, sputtering more and more information, sometimes irrelevant and often damaging, because they are suddenly playing the role of someone who’s goofed and is now trying to recoup. But since the candidate doesn’t know where or how he goofed, he just keeps talking, showing how flustered and confused he is by the interviewer’s unmovable silence.
BEST ANSWER: Like a primitive tribal mask, the Silent Treatment loses all it power to frighten you once you refuse to be intimidated. If your interviewer pulls it, keep quiet yourself for a while and then ask, with sincere politeness and not a trace of sarcasm, “Is there anything else I can fill in on that point?” That’s all there is to it.
Whatever you do, don’t let the Silent Treatment intimidate you into talking a blue streak, because you could easily talk yourself out of the position.
Question 7 Why should I hire you?
TRAPS: Believe it or not, this is a killer question because so many candidates are unprepared for it. If you stammer or adlib you’ve blown it.
BEST ANSWER: By now you can see how critical it is to apply the overall strategy of uncovering the employer’s needs before you answer questions. If you know the employer’s greatest needs and desires, this question will give you a big leg up over other candidates because you will give him better reasons for hiring you than anyone else is likely to…reasons tied directly to his needs.
Whether your interviewer asks you this question explicitly or not, this is the most important question of your interview because he must answer this question favorably in is own mind before you will be hired. So help him out! Walk through each of the position’s requirements as you understand them, and follow each with a reason why you meet that requirement so well.
Example: “As I understand your needs, you are first and foremost looking for someone who can manage the sales and marketing of your book publishing division. As you’ve said you need someone with a strong background in trade book sales. This is where I’ve spent almost all of my career, so I’ve chalked up 18 years of experience exactly in this area. I believe that I know the right contacts, methods, principles, and successful management techniques as well as any person can in our industry.”
“You also need someone who can expand your book distribution channels. In my prior post, my innovative promotional ideas doubled, then tripled, the number of outlets selling our books. I’m confident I can do the same for you.”
“You need someone to give a new shot in the arm to your mail order sales, someone who knows how to sell in space and direct mail media. Here, too, I believe I have exactly the experience you need. In the last five years, I’ve increased our mail order book sales from $600,000 to $2,800,000, and now we’re the country’s second leading marketer of scientific and medical books by mail.” Etc., etc., etc.,
Every one of these selling “couplets” (his need matched by your qualifications) is a touchdown that runs up your score. IT is your best opportunity to outsell your competition.
Question 8 Aren’t you overqualified for this position?
TRAPS: The employer may be concerned that you’ll grow dissatisfied and leave.
BEST ANSWER: As with any objection, don’t view this as a sign of imminent defeat. It’s an invitation to teach the interviewer a new way to think about this situation, seeing advantages instead of drawbacks.
Example: “I recognize the job market for what it is – a marketplace. Like any marketplace, it’s subject to the laws of supply and demand. So ‘overqualified’ can be a relative term, depending on how tight the job market is. And right now, it’s very tight. I understand and accept that.”
“I also believe that there could be very positive benefits for both of us in this match.”
“Because of my unusually strong experience in ________________ , I could start to contribute right away, perhaps much faster than someone who’d have to be brought along more slowly.”
“There’s also the value of all the training and years of experience that other companies have invested tens of thousands of dollars to give me. You’d be getting all the value of that without having to pay an extra dime for it. With someone who has yet to acquire that experience, he’d have to gain it on your nickel.”
“I could also help you in many things they don’t teach at the Harvard Business School. For example…(how to hire, train, motivate, etc.) When it comes to knowing how to work well with people and getting the most out of them, there’s just no substitute for what you learn over many years of front-line experience. You company would gain all this, too.”
“From my side, there are strong benefits, as well. Right now, I am unemployed. I want to work, very much, and the position you have here is exactly what I love to do and am best at. I’ll be happy doing this work and that’s what matters most to me, a lot more that money or title.”
“Most important, I’m looking to make a long term commitment in my career now. I’ve had enough of job-hunting and want a permanent spot at this point in my career. I also know that if I perform this job with excellence, other opportunities cannot help but open up for me right here. In time, I’ll find many other ways to help this company and in so doing, help myself. I really am looking to make a long-term commitment.”
NOTE: The main concern behind the “overqualified” question is that you will leave your new employer as soon as something better comes your way. Anything you can say to demonstrate the sincerity of your commitment to the employer and reassure him that you’re looking to stay for the long-term will help you overcome this objection.
Question 9 Where do you see yourself five years from now?
TRAPS: One reason interviewers ask this question is to see if you’re settling for this position, using it merely as a stopover until something better comes along. Or they could be trying to gauge your level of ambition.
If you’re too specific, i.e., naming the promotions you someday hope to win, you’ll sound presumptuous. If you’re too vague, you’ll seem rudderless.
BEST ANSWER: Reassure your interviewer that you’re looking to make a long-term commitment…that this position entails exactly what you’re looking to do and what you do extremely well. As for your future, you believe that if you perform each job at hand with excellence, future opportunities will take care of themselves.
Example: “I am definitely interested in making a long-term commitment to my next position. Judging by what you’ve told me about this position, it’s exactly what I’m looking for and what I am very well qualified to do. In terms of my future career path, I’m confident that if I do my work with excellence, opportunities will inevitable open up for me. It’s always been that way in my career, and I’m confident I’ll have similar opportunities here.”
Question 10 Describe your ideal company, location and job.
TRAPS: This is often asked by an experienced interviewer who thinks you may be overqualified, but knows better than to show his hand by posing his objection directly. So he’ll use this question instead, which often gets a candidate to reveal that, indeed, he or she is looking for something other than the position at hand.
BEST ANSWER: The only right answer is to describe what this company is offering, being sure to make your answer believable with specific reasons, stated with sincerity, why each quality represented by this opportunity is attractive to you.
Remember that if you’re coming from a company that’s the leader in its field or from a glamorous or much admired company, industry, city or position, your interviewer and his company may well have an “Avis” complex. That is, they may feel a bit defensive about being “second best” to the place you’re coming from, worried that you may consider them bush league.
This anxiety could well be there even though you’ve done nothing to inspire it. You must go out of your way to assuage such anxiety, even if it’s not expressed, by putting their virtues high on the list of exactly what you’re looking for, providing credible reason for wanting these qualities.
If you do not express genuine enthusiasm for the firm, its culture, location, industry, etc., you may fail to answer this “Avis” complex objection and, as a result, leave the interviewer suspecting that a hot shot like you, coming from a Fortune 500 company in New York, just wouldn’t be happy at an unknown manufacturer based in Topeka, Kansas.
Question 11 Why do you want to work at our company?
TRAPS: This question tests whether you’ve done any homework about the firm. If you haven’t, you lose. If you have, you win big.
BEST ANSWER: This question is your opportunity to hit the ball out of the park, thanks to the in-depth research you should do before any interview.
Best sources for researching your target company: annual reports, the corporate newsletter, contacts you know at the company or its suppliers, advertisements, articles about the company in the trade press.
Question 12 What are your career options right now?
TRAPS: The interviewer is trying to find out, “How desperate are you?”
BEST ANSWER: Prepare for this question by thinking of how you can position yourself as a desired commodity. If you are still working, describe the possibilities at your present firm and why, though you’re greatly appreciated there, you’re looking for something more (challenge, money, responsibility, etc.). Also mention that you’re seriously exploring opportunities with one or two other firms.
If you’re not working, you can talk about other employment possibilities you’re actually exploring. But do this with a light touch, speaking only in general terms. You don’t want to seem manipulative or coy.
Question 13 Why have you been out of work so long?
TRAPS: A tough question if you’ve been on the beach a long time. You don’t want to seem like damaged goods.
BEST ANSWER: You want to emphasize factors which have prolonged your job search by your own choice.
Example: “After my job was terminated, I made a conscious decision not to jump on the first opportunities to come along. In my life, I’ve found out that you can always turn a negative into a positive IF you try hard enough. This is what I determined to do. I decided to take whatever time I needed to think through what I do best, what I most want to do, where I’d like to do it…and then identify those companies that could offer such an opportunity.”
“Also, in all honesty, you have to factor in the recession (consolidation, stabilization, etc.) in the (banking, financial services, manufacturing, advertising, etc.) industry.”
“So between my being selective and the companies in our industry downsizing, the process has taken time. But in the end, I’m convinced that when I do find the right match, all that careful evaluation from both sides of the desk will have been well worthwhile for both the company that hires me and myself.
Question 14 Tell me honestly about the strong points and weak points of your boss (company, management team, etc.)…
TRAPS: Skillfull interviewers sometimes make it almost irresistible to open up and air a little dirty laundry from your previous position. DON’T
BEST ANSWER: Remember the rule: Never be negative. Stress only the good points, no matter how charmingly you’re invited to be critical.
Your interviewer doesn’t care a whit about your previous boss. He wants to find out how loyal and positive you are, and whether you’ll criticize him behind his back if pressed to do so by someone in this own company. This question is your opportunity to demonstrate your loyalty to those you work with.
Question 15 What good books have you read lately?
TRAPS: As in all matters of your interview, never fake familiarity you don’t have. Yet you don’t want to seem like a dullard who hasn’t read a book since Tom Sawyer.
BEST ANSWER: Unless you’re up for a position in academia or as book critic for The New York Times, you’re not expected to be a literary lion. But it wouldn’t hurt to have read a handful of the most recent and influential books in your profession and on management.
Consider it part of the work of your job search to read up on a few of these leading books. But make sure they are quality books that reflect favorably upon you, nothing that could even remotely be considered superficial. Finally, add a recently published bestselling work of fiction by a world-class author and you’ll pass this question with flying colors.
Question 16 Tell me about a situation when your work was criticized.
TRAPS: This is a tough question because it’s a more clever and subtle way to get you to admit to a weakness. You can’t dodge it by pretending you’ve never been criticized. Everybody has been. Yet it can be quite damaging to start admitting potential faults and failures that you’d just as soon leave buried.
This question is also intended to probe how well you accept criticism and direction.
BEST ANSWERS: Begin by emphasizing the extremely positive feedback you’ve gotten throughout your career and (if it’s true) that your performance reviews have been uniformly excellent.
Of course, no one is perfect and you always welcome suggestions on how to improve your performance. Then, give an example of a not-too-damaging learning experience from early in your career and relate the ways this lesson has since helped you. This demonstrates that you learned from the experience and the lesson is now one of the strongest breastplates in your suit of armor.
If you are pressed for a criticism from a recent position, choose something fairly trivial that in no way is essential to your successful performance. Add that you’ve learned from this, too, and over the past several years/months, it’s no longer an area of concern because you now make it a regular practice to…etc.
Another way to answer this question would be to describe your intention to broaden your master of an area of growing importance in your field. For example, this might be a computer program you’ve been meaning to sit down and learn… a new management technique you’ve read about…or perhaps attending a seminar on some cutting-edge branch of your profession.
Again, the key is to focus on something not essential to your brilliant performance but which adds yet another dimension to your already impressive knowledge base.
Question 17 What are your outside interests?
TRAPS: You want to be a well-rounded, not a drone. But your potential employer would be even more turned off if he suspects that your heavy extracurricular load will interfere with your commitment to your work duties.
BEST ANSWERS: Try to gauge how this company’s culture would look upon your favorite outside activities and be guided accordingly.
You can also use this question to shatter any stereotypes that could limit your chances. If you’re over 50, for example, describe your activities that demonstrate physical stamina. If you’re young, mention an activity that connotes wisdom and institutional trust, such as serving on the board of a popular charity.
But above all, remember that your employer is hiring your for what you can do for him, not your family, yourself or outside organizations, no matter how admirable those activities may be.
Question 18 The “Fatal Flaw” question
TRAPS: If an interviewer has read your resume carefully, he may try to zero in on a “fatal flaw” of your candidacy, perhaps that you don’t have a college degree…you’ve been out of the job market for some time…you never earned your CPA, etc.
A fatal flaw question can be deadly, but usually only if you respond by being overly defensive.
BEST ANSWERS: As every master salesperson knows, you will encounter objections (whether stated or merely thought) in every sale. They’re part and parcel of the buyer’s anxiety. The key is not to exacerbate the buyer’s anxiety but diminish it. Here’s how…
Whenever you come up against a fatal flaw question:
1. Be completely honest, open and straightforward about admitting the shortcoming. (Showing you have nothing to hide diminishes the buyer’s anxiety.)
2. Do not apologize or try to explain it away. You know that this supposed flaw is nothing to be concerned about, and this is the attitude you want your interviewer to adopt as well.
3. Add that as desirable as such a qualification might be, its lack has made you work all the harder throughout your career and has not prevented you from compiling an outstanding tack record of achievements. You might even give examples of how, through a relentless commitment to excellence, you have consistently outperformed those who do have this qualification.
Of course, the ultimate way to handle “fatal flaw” questions is to prevent them from arising in the first place. You will do that by following the master strategy described in Question 1, i.e., uncovering the employers needs and them matching your qualifications to those needs.
Once you’ve gotten the employer to start talking about his most urgently-felt wants and goals for the position, and then help him see in step-by-step fashion how perfectly your background and achievements match up with those needs, you’re going to have one very enthusiastic interviewer on your hands, one who is no longer looking for “fatal flaws”.
Question 19 How do you feel about reporting to a younger person (minority, woman, etc)?
TRAPS: It’s a shame that some interviewers feel the need to ask this question, but many understand the reality that prejudices still exist among some job candidates, and it’s better to try to flush them out beforehand.
The trap here is that in today’s politically sensitized environment, even a well-intentioned answer can result in planting your foot neatly in your mouth. Avoid anything which smacks of a patronizing or an insensitive attitude, such as “I think they make terrific bosses” or “Hey, some of my best friends are…”
Of course, since almost anyone with an IQ above room temperature will at least try to steadfastly affirm the right answer here, your interviewer will be judging your sincerity most of all. “Do you really feel that way?” is what he or she will be wondering.
So you must make your answer believable and not just automatic. If the firm is wise enough to have promoted peopled on the basis of ability alone, they’re likely quite proud of it, and prefer to hire others who will wholeheartedly share their strong sense of fair play.
BEST ANSWER: You greatly admire a company that hires and promotes on merit alone and you couldn’t agree more with that philosophy. The age (gender, race, etc.) of the person you report to would certainly make no difference to you.
Whoever has that position has obviously earned it and knows their job well. Both the person and the position are fully deserving of respect. You believe that all people in a company, from the receptionist to the Chairman, work best when their abilities, efforts and feelings are respected and rewarded fairly, and that includes you. That’s the best type of work environment you can hope to find.
Question 20 On confidential matters…
TRAPS: When an interviewer presses you to reveal confidential information about a present or former employer, you may feel it’s a no-win situation. If you cooperate, you could be judged untrustworthy. If you don’t, you may irritate the interviewer and seem obstinate, uncooperative or overly suspicious.
BEST ANSWER: Your interviewer may press you for this information for two reasons.
First, many companies use interviews to research the competition. It’s a perfect set-up. Here in their own lair, is an insider from the enemy camp who can reveal prized information on the competition’s plans, research, financial condition, etc.
Second, the company may be testing your integrity to see if you can be cajoled or bullied into revealing confidential data.
What to do? The answer here is easy. Never reveal anything truly confidential about a present or former employer. By all means, explain your reticence diplomatically. For example, “I certainly want to be as open as I can about that. But I also wish to respect the rights of those who have trusted me with their most sensitive information, just as you would hope to be able to trust any of your key people when talking with a competitor…”
And certainly you can allude to your finest achievements in specific ways that don’t reveal the combination to the company safe.
But be guided by the golden rule. If you were the owner of your present company, would you feel it ethically wrong for the information to be given to your competitors? If so, steadfastly refuse to reveal it.
Remember that this question pits your desire to be cooperative against your integrity. Faced with any such choice, always choose integrity. It is a far more valuable commodity than whatever information the company may pry from you. Moreover, once you surrender the information, your stock goes down. They will surely lose respect for you.
One President we know always presses candidates unmercifully for confidential information. If he doesn’t get it, he grows visibly annoyed, relentlessly inquisitive, It’s all an act. He couldn’t care less about the information. This is his way of testing the candidate’s moral fiber. Only those who hold fast are hired.
Question 21 Would you lie for the company?
TRAPS: This another question that pits two values against one another, in this case loyalty against integrity.
BEST ANSWER: Try to avoid choosing between two values, giving a positive statement which covers all bases instead.
Example: “I would never do anything to hurt the company..”
If aggressively pressed to choose between two competing values, always choose personal integrity. It is the most prized of all values.
Question 22 Looking back, what would you do differently in your life?
TRAPS: This question is usually asked to uncover any life-influencing mistakes, regrets, disappointments or problems that may continue to affect your personality and performance.
You do not want to give the interviewer anything negative to remember you by, such as some great personal or career disappointment, even long ago, that you wish could have been avoided.
Nor do you wish to give any answer which may hint that your whole heart and soul will not be in your work.
BEST ANSWER: Indicate that you are a happy, fulfilled, optimistic person and that, in general, you wouldn’t change a thing.
Example: “It’s been a good life, rich in learning and experience, and the best it yet to come. Every experience in life is a lesson it its own way. I wouldn’t change a thing.”
Question 23 Could you have done better in your last job?
TRAPS: This is no time for true confessions of major or even minor problems.
BEST ANSWER: Again never be negative.
Example: “I suppose with the benefit of hindsight you can always find things to do better, of course, but off the top of my head, I can’t think of anything of major consequence.”
(If more explanation seems necessary) Describer a situation that didn’t suffer because of you but from external conditions beyond your control.
For example, describe the disappointment you felt with a test campaign, new product launch, merger, etc., which looked promising at first, but led to underwhelming results. “I wish we could have known at the start what we later found out (about the economy turning, the marketplace changing, etc.), but since we couldn’t, we just had to go for it. And we did learn from it…”
Question 24 Can you work under pressure?
TRAPS: An easy question, but you want to make your answer believable.
BEST ANSWER: Absolutely…(then prove it with a vivid example or two of a goal or project accomplished under severe pressure.)
Question 25 What makes you angry?
TRAPS: You don’t want to come across either as a hothead or a wimp.
BEST ANSWER: Give an answer that’s suited to both your personality and the management style of the firm. Here, the homework you’ve done about the company and its style can help in your choice of words.
Examples: If you are a reserved person and/or the corporate culture is coolly professional:
“I’m an even-tempered and positive person by nature, and I believe this helps me a great deal in keeping my department running smoothly, harmoniously and with a genuine esprit de corps. I believe in communicating clearly what’s expected, getting people’s commitment to those goals, and then following up continuously to check progress.”
“If anyone or anything is going off track, I want to know about it early. If, after that kind of open communication and follow up, someone isn’t getting the job done, I’ll want to know why. If there’s no good reason, then I’ll get impatient and angry…and take appropriate steps from there. But if you hire good people, motivate them to strive for excellence and then follow up constantly, it almost never gets to that state.”
If you are feisty by nature and/or the position calls for a tough straw boss.
“You know what makes me angry? People who (the fill in the blanks with the most objectionable traits for this type of position)…people who don’t pull their own weight, who are negative, people who lie…etc.”
Question 26 Why aren’t you earning more money at this stage of your career?
TRAPS: You don’t want to give the impression that money is not important to you, yet you want to explain why your salary may be a little below industry standards.
BEST ANSWER: You like to make money, but other factors are even more important.
Example: “Making money is very important to me, and one reason I’m here is because I’m looking to make more. Throughout my career, what’s been even more important to me is doing work I really like to do at the kind of company I like and respect.
(Then be prepared to be specific about what your ideal position and company would be like, matching them as closely as possible to the opportunity at hand.
Question 27 Who has inspired you in your life and why?
TRAPS: The two traps here are unpreparedness and irrelevance. If you grope for an answer, it seems you’ve never been inspired. If you ramble about your high school basketball coach, you’ve wasted an opportunity to present qualities of great value to the company.
BEST ANSWER: Have a few heroes in mind, from your mental “Board of Directors” – Leaders in your industry, from history or anyone else who has been your mentor.
Be prepared to give examples of how their words, actions or teachings have helped inspire your achievements. As always, prepare an answer which highlights qualities that would be highly valuable in the position you are seeking.
Question 28 What was the toughest decision you ever had to make?
TRAPS: Giving an unprepared or irrelevant answer.
BEST ANSWER: Be prepared with a good example, explaining why the decision was difficult…the process you followed in reaching it…the courageous or effective way you carried it out…and the beneficial results.
Question 29 Tell me about the most boring job you’ve ever had.
TRAPS: You give a very memorable description of a very boring job. Result? You become associated with this boring job in the interviewer’s mind.
BEST ANSWER: You have never allowed yourself to grow bored with a job and you can’t understand it when others let themselves fall into that rut.
Example: “Perhaps I’ve been fortunate, but that I’ve never found myself bored with any job I have ever held. I’ve always enjoyed hard work. As with actors who feel there are no small parts, I also believe that in every company or department there are exciting challenges and intriguing problems crying out for energetic and enthusiastic solutions. If you’re bored, it’s probably because you’re not challenging yourself to tackle those problems right under your nose.”
Question 30 Have you been absent from work more than a few days in any previous position?
TRAPS: If you’ve had a problem, you can’t lie. You could easily be found out. Yet admitting an attendance problem could raise many flags.
BEST ANSWER: If you have had no problem, emphasize your excellent and consistent attendance record throughout your career.
Also describe how important you believe such consistent attendance is for a key executive…why it’s up to you to set an example of dedication…and why there’s just no substitute for being there with your people to keep the operation running smoothly, answer questions and handle problems and crises as they arise.
If you do have a past attendance problem, you want to minimize it, making it clear that it was an exceptional circumstance and that it’s cause has been corrected.
To do this, give the same answer as above but preface it with something like, “Other that being out last year (or whenever) because of (your reason, which is now in the past), I have never had a problem and have enjoyed an excellent attendance record throughout my career. Furthermore, I believe, consistent attendance is important because…” (Pick up the rest of the answer as outlined above.).
Question 31 What changes would you make if you came on board?
TRAPS: Watch out! This question can derail your candidacy faster than a bomb on the tracks – and just as you are about to be hired.
Reason: No matter how bright you are, you cannot know the right actions to take in a position before you settle in and get to know the operation’s strengths, weaknesses key people, financial condition, methods of operation, etc. If you lunge at this temptingly baited question, you will probably be seen as someone who shoots from the hip.
Moreover, no matter how comfortable you may feel with your interviewer, you are still an outsider. No one, including your interviewer, likes to think that a know-it-all outsider is going to come in, turn the place upside down and with sweeping, grand gestures, promptly demonstrate what jerks everybody’s been for years.
BEST ANSWER: You, of course, will want to take a good hard look at everything the company is doing before making any recommendations.
Example: “Well, I wouldn’t be a very good doctor if I gave my diagnosis before the examination. Should you hire me, as I hope you will, I’d want to take a good hard look at everything you’re doing and understand why it’s being done that way. I’d like to have in-depth meetings with you and the other key people to get a deeper grasp of what you feel you’re doing right and what could be improved.
“From what you’ve told me so far, the areas of greatest concern to you are…” (name them. Then do two things. First, ask if these are in fact his major concerns. If so then reaffirm how your experience in meeting similar needs elsewhere might prove very helpful).
Question 32 I’m concerned that you don’t have as much experience as we’d like in…
TRAPS: This could be a make-or-break question. The interviewer mostly likes what he sees, but has doubts over one key area. If you can assure him on this point, the job may be yours.
BEST ANSWER: This question is related to “The Fatal Flaw” (Question 18), but here the concern is not that you are totally missing some qualifications, such as CPA certification, but rather that your experience is light in one area.
Before going into any interview, try to identify the weakest aspects of your candidacy from this company’s point of view. Then prepare the best answer you possible can to shore up your defenses.
To get past this question with flying colors, you are going to rely on your master strategy of uncovering the employer’s greatest wants and needs and then matching them with your strengths. Since you already know how to do this from Question 1, you are in a much stronger position.
More specifically, when the interviewer poses as objection like this, you should…
1. Agree on the importance of this qualification.
2. Explain that your strength may be indeed be greater than your resume indicates because…
3. When this strength is added to your other strengths, it’s really your combination of qualifications that’s most important.
Then review the areas of your greatest strengths that match up most favorably with the company’s most urgently-felt wants and needs.
This is powerful way to handle this question for two reasons. First, you’re giving your interviewer more ammunition in the area of his concern. But more importantly, you’re shifting his focus away from this one, isolated area and putting it on the unique combination of strengths you offer, strengths which tie in perfectly with his greatest wants.
Question 33 How do you feel about working nights and weekends?
TRAPS: Blurt out “no way, Jose” and you can kiss the job offer goodbye. But what if you have a family and want to work a reasonably normal schedule? Is there a way to get both the job and the schedule you want?
BEST ANSWER: First, if you’re a confirmed workaholic, this question is a softball lob. Whack it out of the park on the first swing by saying this kind of schedule is just your style. Add that your family understands it. Indeed, they’re happy for you, as they know you get your greatest satisfaction from your work.
If however, you prefer a more balanced lifestyle, answer this question with another: “What’s the norm for your best people here?”
If the hours still sound unrealistic for you, ask, “Do you have any top people who perform exceptionally for you, but who also have families and like to get home in time to see them at night?” Chances are this company does, and this associates you with this other “top-performers-who-leave-not-later-than-six” group.
Depending on the answer, be honest about how you would fit into the picture. If all those extra hours make you uncomfortable, say so, but phrase your response positively.
Example: “I love my work and do it exceptionally well. I think the results speak for themselves, especially in …(mention your two or three qualifications of greater interest to the employer. Remember, this is what he wants most, not a workaholic with weak credentials). Not only would I bring these qualities, but I’ve built my whole career on working not just hard, but smart. I think you’ll find me one of the most productive people here.
I do have a family who likes to see me after work and on weekends. They add balance and richness to my life, which in turn helps me be happy and productive at work. If I could handle some of the extra work at home in the evenings or on weekends, that would be ideal. You’d be getting a person of exceptional productivity who meets your needs with strong credentials. And I’d be able to handle some of the heavy workload at home where I can be under the same roof as my family. Everybody would win.”
Question 34 Are you willing to relocate or travel?
TRAPS: Answer with a flat “no” and you may slam the door shut on this opportunity. But what if you’d really prefer not to relocate or travel, yet wouldn’t want to lose the job offer over it?
BEST ANSWER: First find out where you may have to relocate and how much travel may be involved. Then respond to the question.
If there’s no problem, say so enthusiastically.
If you do have a reservation, there are two schools of thought on how to handle it.
One advises you to keep your options open and your reservations to yourself in the early going, by saying, “no problem”. You strategy here is to get the best offer you can, then make a judgment whether it’s worth it to you to relocate or travel.
Also, by the time the offer comes through, you may have other offers and can make a more informed decision. Why kill of this opportunity before it has chance to blossom into something really special? And if you’re a little more desperate three months from now, you might wish you hadn’t slammed the door on relocating or traveling.
The second way to handle this question is to voice a reservation, but assert that you’d be open to relocating (or traveling) for the right opportunity.
The answering strategy you choose depends on how eager you are for the job. If you want to take no chances, choose the first approach.
If you want to play a little harder-to-get in hopes of generating a more enticing offer, choose the second.
Question 35 Do you have the stomach to fire people? Have you had experience firing many people?
TRAPS: This “innocent” question could be a trap door which sends you down a chute and lands you in a heap of dust outside the front door. Why? Because its real intent is not just to see if you’ve got the stomach to fire, but also to uncover poor judgment in hiring which has caused you to fire so many. Also, if you fire so often, you could be a tyrant.
So don’t rise to the bait by boasting how many you’ve fired, unless you’ve prepared to explain why it was beyond your control, and not the result of your poor hiring procedures or foul temperament.
BEST ANSWER: Describe the rational and sensible management process you follow in both hiring and firing.
Example: “My whole management approach is to hire the best people I can find, train them thoroughly and well, get them excited and proud to be part of our team, and then work with them to achieve our goals together. If you do all of that right, especially hiring the right people, I’ve found you don’t have to fire very often.
“So with me, firing is a last resort. But when it’s got to be done, it’s got to be done, and the faster and cleaner, the better. A poor employee can wreak terrible damage in undermining the morale of an entire team of good people. When there’s no other way, I’ve found it’s better for all concerned to act decisively in getting rid of offenders who won’t change their ways.”
Question 36 Why have you had so many jobs?
TRAPS: Your interviewer fears you may leave this position quickly, as you have others. He’s concerned you may be unstable, or a “problem person” who can’t get along with others.
BEST ANSWER: First, before you even get to the interview stage, you should try to minimize your image as job hopper. If there are several entries on your resume of less than one year, consider eliminating the less important ones. Perhaps you can specify the time you spent at previous positions in rounded years not in months and years.
Example: Instead of showing three positions this way:
6/1982 – 3/1983, Position A;4/1983 – 12/1983, Position B;1/1984 – 8/1987, Position C;
…it would be better to show simply:
1982 – 1983, Position A;1984 – 1987 Position C.
In other words, you would drop Position B altogether. Notice what a difference this makes in reducing your image as a job hopper.
Once in front of the interviewer and this question comes up, you must try to reassure him. Describe each position as part of an overall pattern of growth and career destination.
Be careful not to blame other people for your frequent changes. But you can and should attribute certain changes to conditions beyond your control.
Example: Thanks to an upcoming merger, you wanted to avoid an ensuing bloodbath, so you made a good, upward career move before your department came under the axe of the new owners.
If possible, also show that your job changes were more frequent in your younger days, while you were establishing yourself, rounding out your skills and looking for the right career path. At this stage in your career, you’re certainly much more interested in the best long-term opportunity.
You might also cite the job(s) where you stayed the longest and describe that this type of situation is what you’re looking for now.
Question 37 What do you see as the proper role/mission of……a good (job title you’re seeking);…a good manager;…an executive in serving the community;…a leading company in our industry; etc.
TRAPS: These and other “proper role” questions are designed to test your understanding of your place in the bigger picture of your department, company, community and profession….as well as the proper role each of these entities should play in its bigger picture.
The question is most frequently asked by the most thoughtful individuals and companies…or by those concerned that you’re coming from a place with a radically different corporate culture (such as from a big government bureaucracy to an aggressive small company).
The most frequent mistake executives make in answering is simply not being prepared (seeming as if they’ve never giving any of this a though.)…or in phrasing an answer best suited to their prior organization’s culture instead of the hiring company’s.
BEST ANSWER: Think of the most essential ingredients of success for each category above – your job title, your role as manager, your firm’s role, etc.
Identify at least three but no more than six qualities you feel are most important to success in each role. Then commit your response to memory.
Here, again, the more information you’ve already drawn out about the greatest wants and needs of the interviewer, and the more homework you’ve done to identify the culture of the firm, the more on-target your answer will be.
Question 38 What would you say to your boss if he’s crazy about an idea, but you think it stinks?
TRAPS: This is another question that pits two values, in this case loyalty and honesty, against one another.
BEST ANSWER: Remember the rule stated earlier: In any conflict between values, always choose integrity.
Example: I believe that when evaluating anything, it’s important to emphasize the positive. What do I like about this idea?”
“Then, if you have reservations, I certainly want to point them out, as specifically, objectively and factually as I can.”
“After all, the most important thing I owe my boss is honesty. If he can’t count on me for that, then everything else I may do or say could be questionable in his eyes.”
“But I also want to express my thoughts in a constructive way. So my goal in this case would be to see if my boss and I could make his idea even stronger and more appealing, so that it effectively overcomes any initial reservation I or others may have about it.”
“Of course, if he overrules me and says, ‘no, let’s do it my way,’ then I owe him my full and enthusiastic support to make it work as best it can.”
Question 39 How could you have improved your career progress?
TRAPS: This is another variation on the question, “If you could, how would you live your life over?” Remember, you’re not going to fall for any such invitations to rewrite person history. You can’t win if you do.
BEST ANSWER: You’re generally quite happy with your career progress. Maybe, if you had known something earlier in life (impossible to know at the time, such as the booming growth in a branch in your industry…or the corporate downsizing that would phase out your last job), you might have moved in a certain direction sooner.
But all things considered, you take responsibility for where you are, how you’ve gotten there, where you are going…and you harbor no regrets.
Question 40 What would you do if a fellow executive on your own corporate level wasn’t pulling his/her weight…and this was hurting your department?
TRAPS: This question and other hypothetical ones test your sense of human relations and how you might handle office politics.
BEST ANSWER: Try to gauge the political style of the firm and be guided accordingly. In general, fall back on universal principles of effective human relations – which in the end, embody the way you would like to be treated in a similar circumstance.
Example: “Good human relations would call for me to go directly to the person and explain the situation, to try to enlist his help in a constructive, positive solution. If I sensed resistance, I would be as persuasive as I know how to explain the benefits we can all gain from working together, and the problems we, the company and our customers will experience if we don’t.”
POSSIBLE FOLLOW-UP QUESTION: And what would you do if he still did not change his ways?
ANSWER: “One thing I wouldn’t do is let the problem slide, because it would only get worse and overlooking it would set a bad precedent. I would try again and again and again, in whatever way I could, to solve the problem, involving wider and wider circles of people, both above and below the offending executive and including my own boss if necessary, so that everyone involved can see the rewards for teamwork and the drawbacks of non-cooperation.”
“I might add that I’ve never yet come across a situation that couldn’t be resolved by harnessing others in a determined, constructive effort.”
Question 41 You’ve been with your firm a long time. Won’t it be hard switching to a new company?
TRAPS: Your interviewer is worried that this old dog will find it hard to learn new tricks.
BEST ANSWER: To overcome this objection, you must point to the many ways you have grown and adapted to changing conditions at your present firm. It has not been a static situation. Highlight the different responsibilities you’ve held, the wide array of new situations you’ve faced and conquered.
As a result, you’ve learned to adapt quickly to whatever is thrown at you, and you thrive on the stimulation of new challenges.
To further assure the interviewer, describe the similarities between the new position and your prior one. Explain that you should be quite comfortable working there, since their needs and your skills make a perfect match.
Question 42 May I contact your present employer for a reference?
TRAPS: If you’re trying to keep your job search private, this is the last thing you want. But if you don’t cooperate, won’t you seem as if you’re trying to hide something?
BEST ANSWER: Express your concern that you’d like to keep your job search private, but that in time, it will be perfectly okay.
Example: “My present employer is not aware of my job search and, for obvious reasons; I’d prefer to keep it that way. I’d be most appreciative if we kept our discussion confidential right now. Of course, when we both agree the time is right, then by all means you should contact them. I’m very proud of my record there.
Question 43 Give me an example of your creativity (analytical skill…managing ability, etc.)
TRAPS: The worst offense here is simply being unprepared. Your hesitation may seem as if you’re having a hard time remembering the last time you were creative, analytical, etc.
BEST ANSWER: Remember from Question 2 that you should commit to memory a list of your greatest and most recent achievements, ever ready on the tip of your tongue.
If you have such a list, it’s easy to present any of your achievements in light of the quality the interviewer is asking about. For example, the smashing success you orchestrated at last year’s trade show could be used as an example of creativity, or analytical ability, or your ability to manage.
Question 44 Where could you use some improvement?
TRAPS: Another tricky way to get you to admit weaknesses. Don’t fall for it.
BEST ANSWER: Keep this answer, like all your answers, positive. A good way to answer this question is to identify a cutting-edge branch of your profession (one that’s not essential to your employer’s needs) as an area you’re very excited about and want to explore more fully over the next six months.
Question 45 What do you worry about?
TRAPS: Admit to worrying and you could sound like a loser. Saying you never worry doesn’t sound credible.
BEST ANSWER: Redefine the word ‘worry’ so that it does not reflect negatively on you.
Example: “I wouldn’t call it worry, but I am a strongly goal-oriented person. So I keep turning over in my mind anything that seems to be keeping me from achieving those goals, until I find a solution. That’s part of my tenacity, I suppose.”
Question 46 How many hours a week do you normally work?
TRAPS: You don’t want to give a specific number. Make it to low, and you may not measure up. Too high, and you’ll forever feel guilty about sneaking out the door at 5:15.
BEST ANSWER: If you are in fact a workaholic and you sense this company would like that: Say you are a confirmed workaholic, that you often work nights and weekends. Your family accepts this because it makes you fulfilled.
If you are not a workaholic: Say you have always worked hard and put in long hours. It goes with the territory. It one sense, it’s hard to keep track of the hours because your work is a labor of love, you enjoy nothing more than solving problems. So you’re almost always thinking about your work, including times when you’re home, while shaving in the morning, while commuting, etc.
Question 47 What’s the most difficult part of being a (job title)?
TRAPS: Unless you phrase your answer properly, your interviewer may conclude that whatever you identify as “difficult” is where you are weak.
BEST ANSWER: First, redefine “difficult” to be “challenging” which is more positive. Then, identify an area everyone in your profession considers challenging and in which you excel. Describe the process you follow that enables you to get splendid results…and be specific about those results.
Example: “I think every sales manager finds it challenging to motivate the troops in a recession. But that’s probably the strongest test of a top sales manager. I feel this is one area where I excel.”
“When I see the first sign that sales may slip or that sales force motivation is flagging because of a downturn in the economy, here’s the plan I put into action immediately…” (followed by a description of each step in the process…and most importantly, the exceptional results you’ve achieved.).
Question 48 The “Hypothetical Problem”
TRAPS: Sometimes an interviewer will describe a difficult situation and ask, “How would you handle this?” Since it is virtually impossible to have all the facts in front of you from such a short presentation, don’t fall into the trap of trying to solve this problem and giving your verdict on the spot. It will make your decision-making process seem woefully inadequate.
BEST ANSWER: Instead, describe the rational, methodical process you would follow in analyzing this problem, who you would consult with, generating possible solutions, choosing the best course of action, and monitoring the results.
Remember, in all such, “What would you do?” questions, always describe your process or working methods, and you’ll never go wrong.
Question 49 What was the toughest challenge you’ve ever faced?
TRAPS: Being unprepared or citing an example from so early in your life that it doesn’t score many points for you at this stage of your career.
BEST ANSWER: This is an easy question if you’re prepared. Have a recent example ready that demonstrates either:
1. A quality most important to the job at hand; or
2. A quality that is always in demand, such as leadership, initiative, managerial skill, persuasiveness, courage, persistence, intelligence, etc.
Question 50 Have you consider starting your own business?
TRAPS: If you say “yes” and elaborate enthusiastically, you could be perceived as a loose cannon in a larger company, too entrepreneurial to make a good team player…or someone who had to settle for the corporate life because you couldn’t make a go of your own business.
Also too much enthusiasm in answering “yes” could rouse the paranoia of a small company indicating that you may plan to go out on your own soon, perhaps taking some key accounts or trade secrets with you.
On the other hand, if you answer “no, never” you could be perceived as a security-minded drone who never dreamed a big dream.
BEST ANSWER: Again it’s best to:
1. Gauge this company’s corporate culture before answering and…
2. Be honest (which doesn’t mean you have to vividly share your fantasy of the franchise or bed-and-breakfast you someday plan to open).
In general, if the corporate culture is that of a large, formal, military-style structure, minimize any indication that you’d love to have your own business. You might say, “Oh, I may have given it a thought once or twice, but my whole career has been in larger organizations. That’s where I have excelled and where I want to be.”
If the corporate culture is closer to the free-wheeling, everybody’s-a-deal-maker variety, then emphasize that in a firm like this, you can virtually get the best of all worlds, the excitement of seeing your own ideas and plans take shape…combined with the resources and stability of a well-established organization. Sounds like the perfect environment to you.
In any case, no matter what the corporate culture, be sure to indicate that any desires about running your own show are part of your past, not your present or future.
The last thing you want to project is an image of either a dreamer who failed and is now settling for the corporate cocoon…or the restless maverick who will fly out the door with key accounts, contacts and trade secrets under his arms just as soon as his bankroll has gotten rebuilt.
Always remember: Match what you want with what the position offers. The more information you’ve uncovered about the position, the more believable you can make your case.
Question 51 What are your goals?
TRAPS: Not having any…or having only vague generalities, not highly specific goals.
BEST ANSWER: Many executives in a position to hire you are strong believers in goal-setting. (It’s one of the reason they’ve achieved so much). They like to hire in kind.
If you’re vague about your career and personal goals, it could be a big turnoff to may people you will encounter in your job search.
Be ready to discuss your goals for each major area of your life: career, personal development and learning, family, physical (health), community service and (if your interviewer is clearly a religious person) you could briefly and generally allude to your spiritual goals (showing you are a well-rounded individual with your values in the right order).
Be prepared to describe each goal in terms of specific milestones you wish to accomplish along the way, time periods you’re allotting for accomplishment, why the goal is important to you, and the specific steps you’re taking to bring it about. But do this concisely, as you never want to talk more than two minutes straight before letting your interviewer back into the conversation.
Question 52 What do you for when you hire people?
TRAPS: Being unprepared for the question.
BEST ANSWER: Speak your own thoughts here, but for the best answer weave them around the three most important qualifications for any position.
1. Can the person do the work (qualifications)?
2. Will the person do the work (motivation)?
3. Will the person fit in (“our kind of team player”)?
Question 53 Sell me this stapler…(this pencil…this clock…or some other object on interviewer’s desk).
TRAPS: Some interviewers, especially business owners and hard-changing executives in marketing-driven companies, feel that good salesmanship is essential for any key position and ask for an instant demonstration of your skill. Be ready.
BEST ANSWER: Of course, you already know the most important secret of all great salesmanship – “find out what people want, then show them how to get it.”
If your interviewer picks up his stapler and asks, “sell this to me,” you are going to demonstrate this proven master principle. Here’s how:
“Well, a good salesman must know both his product and his prospect before he sells anything. If I were selling this, I’d first get to know everything I could about it, all its features and benefits.”
“Then, if my goal were to sell it you, I would do some research on how you might use a fine stapler like this. The best way to do that is by asking some questions. May I ask you a few questions?”
Then ask a few questions such as, “Just out of curiosity, if you didn’t already have a stapler like this, why would you want one? And in addition to that? Any other reason? Anything else?”
“And would you want such a stapler to be reliable?...Hold a good supply of staples?” (Ask more questions that point to the features this stapler has.)
Once you’ve asked these questions, make your presentation citing all the features and benefits of this stapler and why it’s exactly what the interviewer just told you he’s looking for.
Then close with, “Just out of curiosity, what would you consider a reasonable price for a quality stapler like this…a stapler you could have right now and would (then repeat all the problems the stapler would solve for him)? Whatever he says, (unless it’s zero), say, “Okay, we’ve got a deal.”
NOTE: If your interviewer tests you by fighting every step of the way, denying that he even wants such an item, don’t fight him. Take the product away from him by saying, “Mr. Prospect, I’m delighted you’ve told me right upfront that there’s no way you’d ever want this stapler. As you well know, the first rule of the most productive salespeople in any field is to meet the needs of people who really need and want our products, and it just wastes everyone’s time if we try to force it on those who don’t. And I certainly wouldn’t want to waste your time. But we sell many items. Is there any product on this desk you would very much like to own…just one item?” When he points something out, repeat the process above. If he knows anything about selling, he may give you a standing ovation.
Question 54 “The Salary Question” – How much money do you want?
TRAPS: May also be phrases as, “What salary are you worth?”…or, “How much are you making now?” This is your most important negotiation. Handle it wrong and you can blow the job offer or go to work at far less than you might have gotten.
BEST ANSWER: For maximum salary negotiating power, remember these five guidelines:
1. Never bring up salary. Let the interviewer do it first. Good salespeople sell their products thoroughly before talking price. So should you. Make the interviewer want you first, and your bargaining position will be much stronger.
2. If your interviewer raises the salary question too early, before you’ve had a chance to create desire for your qualifications, postpone the question, saying something like, “Money is important to me, but is not my main concern. Opportunity and growth are far more important. What I’d rather do, if you don’t mind, is explore if I’m right for the position, and then talk about money. Would that be okay?”
3. The #1 rule of any negotiation is: the side with more information wins. After you’ve done a thorough job of selling the interviewer and it’s time to talk salary, the secret is to get the employer talking about what he’s willing to pay before you reveal what you’re willing to accept. So, when asked about salary, respond by asking, “I’m sure the company has already established a salary range for this position. Could you tell me what that is?” Or, “I want an income commensurate with my ability and qualifications. I trust you’ll be fair with me. What does the position pay?” Or, more simply, “What does this position pay?”
4. Know beforehand what you’d accept. To know what’s reasonable, research the job market and this position for any relevant salary information. Remember that most executives look for a 20-25%$ pay boost when they switch jobs. If you’re grossly underpaid, you may want more.
5. Never lie about what you currently make, but feel free to include the estimated cost of all your fringes, which could well tack on 25-50% more to your present “cash-only” salary.
Question 55 The Illegal Question
TRAPS: Illegal questions include any regarding your age…number and ages of your children or other dependents…marital status…maiden name…religion…political affiliation…ancestry…national origin…birthplace…naturalization of your parents, spouse or children…diseases…disabilities…clubs…or spouse’s occupation…unless any of the above are directly related to your performance of the job. You can’t even be asked about arrests, though you can be asked about convictions.
BEST ANSWER: Under the ever-present threat of lawsuits, most interviewers are well aware of these taboos. Yet you may encounter, usually on a second or third interview, a senior executive who doesn’t interview much and forgets he can’t ask such questions.
You can handle an illegal question in several ways. First, you can assert your legal right not to answer. But this will frighten or embarrass your interviewer and destroy any rapport you had.
Second, you could swallow your concerns over privacy and answer the question straight forwardly if you feel the answer could help you. For example, your interviewer, a devout Baptist, recognizes you from church and mentions it. Here, you could gain by talking about your church.
Third, if you don’t want your privacy invaded, you can diplomatically answer the concern behind the question without answering the question itself.
Example: If you are over 50 and are asked, “How old are you?” you can answer with a friendly, smiling question of your own on whether there’s a concern that your age my affect your performance. Follow this up by reassuring the interviewer that there’s nothing in this job you can’t do and, in fact, your age and experience are the most important advantages you offer the employer for the following reasons…
Another example: If asked, “Do you plan to have children?” you could answer, “I am wholeheartedly dedicated to my career“, perhaps adding, “I have no plans regarding children.” (You needn’t fear you’ve pledged eternal childlessness. You have every right to change your plans later. Get the job first and then enjoy all your options.)
Most importantly, remember that illegal questions arise from fear that you won’t perform well. The best answer of all is to get the job and perform brilliantly. All concerns and fears will then varnish, replaced by respect and appreciation for your work.
Question 56 The “Secret” Illegal Question
TRAPS: Much more frequent than the Illegal question (see Question 55) is the secret illegal question. It’s secret because it’s asked only in the interviewer’s mind. Since it’s not even expressed to you, you have no way to respond to it, and it can there be most damaging.
Example: You’re physically challenged, or a single mother returning to your professional career, or over 50, or a member of an ethnic minority, or fit any of a dozen other categories that do not strictly conform to the majority in a given company.
Your interviewer wonders, “Is this person really able to handle the job?”…”Is he or she a ‘good fit’ at a place like ours?”…”Will the chemistry ever be right with someone like this?” But the interviewer never raises such questions because they’re illegal. So what can you do?
BEST ANSWER: Remember that just because the interviewer doesn’t ask an illegal question doesn’t mean he doesn’t have it. More than likely, he is going to come up with his own answer. So you might as well help him out.
How? Well, you obviously can’t respond to an illegal question if he hasn’t even asked. This may well offend him. And there’s always the chance he wasn’t even concerned about the issue until you brought it up, and only then begins to wonder.
So you can’t address “secret” illegal questions head-on. But what you can do is make sure there’s enough counterbalancing information to more than reassure him that there’s no problem in the area he may be doubtful about.
For example, let’s say you’re a sales rep who had polio as a child and you need a cane to walk. You know your condition has never impeded your performance, yet you’re concerned that your interviewer may secretly be wondering about your stamina or ability to travel. Well, make sure that you hit these abilities very hard, leaving no doubt about your capacity to handle them well.
So, too, if you’re in any different from what passes for “normal”. Make sure, without in any way seeming defensive about yourself that you mention strengths, accomplishments, preferences and affiliations that strongly counterbalance any unspoken concern your interviewer may have.
Question 57 What was the toughest part of your last job?
TRAPS: This is slightly different from the question raised earlier, “What’s the most difficult part of being a (job title…)” because this asks what you personally have found most difficult in your last position. This question is more difficult to redefine into something positive. Your interviewer will assume that whatever you found toughest may give you a problem in your new position.
BEST ANSWER: State that there was nothing in your prior position that you found overly difficult, and let your answer go at that. If pressed to expand your answer, you could describe the aspects of the position you enjoyed more than others, making sure that you express maximum enjoyment for those tasks most important to the open position, and you enjoyed least those tasks that are unimportant to the position at hand.
Question 58 How do you define success…and how do you measure up to your own definition?
TRAPS: Seems like an obvious enough question. Yet many executives, unprepared for it, fumble the ball.
BEST ANSWER: Give a well-accepted definition of success that leads right into your own stellar collection of achievements.
Example: “The best definition I’ve come across is that success is the progressive realization of a worthy goal.”
“As to how I would measure up to that definition, I would consider myself both successful and fortunate…”(Then summarize your career goals and how your achievements have indeed represented a progressive path toward realization of your goals.)
Question 59 “The Opinion Question” – What do you think about …Abortion…The President…The Death Penalty…(or any other controversial subject)?
TRAPS: Obviously, these and other “opinion” questions should never be asked. Sometimes they come up over a combination dinner/interview when the interviewer has had a drink or two, is feeling relaxed, and is spouting off about something that bugged him in today’s news. If you give your opinion and it’s the opposite of his, you won’t change his opinions, but you could easily lose the job offer.
BEST ANSWER: In all of these instances, just remember the tale about student and the wise old rabbi. The scene is a seminary, where an overly serious student is pressing the rabbi to answer the ultimate questions of suffering, life and death. But no matter how hard he presses, the wise old rabbi will only answer each difficult question with a question of his own.
In exasperation, the seminary student demands, “Why, rabbi, do you always answer a question with another question?” To which the rabbi responds, “And why not?”
If you are ever uncomfortable with any question, asking a question in return is the greatest escape hatch ever invented. It throws the onus back on the other person, sidetracks the discussion from going into an area of risk to you, and gives you time to think of your answer or, even better, your next question!
In response to any of the “opinion” questions cited above, merely responding, “Why do you ask?” will usually be enough to dissipate any pressure to give your opinion. But if your interviewer again presses you for an opinion, you can ask another question.
Or you could assert a generality that almost everyone would agree with. For example, if your interviewer is complaining about politicians then suddenly turns to you and asks if you’re a Republican or Democrat, you could respond by saying, “Actually, I’m finding it hard to find any politicians I like these days.”
(Of course, your best question of all may be whether you want to work for someone opinionated.)
Question 60 If you won $10 million lottery, would you still work?
TRAPS: Your totally honest response might be, “Hell, no, are you serious?” That might be so, but any answer which shows you as fleeing work if given the chance could make you seem lazy. On the other hand, if you answer, “Oh, I’d want to keep doing exactly what I am doing, only doing it for your firm,” you could easily inspire your interviewer to silently mutter to himself, “Yeah, sure. Gimme a break.”
BEST ANSWER: This type of question is aimed at getting at your bedrock attitude about work and how you feel about what you do. Your best answer will focus on your positive feelings.
Example: “After I floated down from cloud nine, I think I would still hold my basic belief that achievement and purposeful work are essential to a happy, productive life. After all, if money alone bought happiness, then all rich people would be all happy, and that’s not true.
“I love the work I do, and I think I’d always want to be involved in my career in some fashion. Winning the lottery would make it more fun because it would mean having more flexibility, more options...who knows?”
“Of course, since I can’t count on winning, I’d just as soon create my own destiny by sticking with what’s worked for me, meaning good old reliable hard work and a desire to achieve. I think those qualities have built many more fortunes that all the lotteries put together.”
Question 61 Looking back on your last position, have you done your best work?
TRAPS: Tricky question. Answer “absolutely” and it can seem like your best work is behind you. Answer, “no, my best work is ahead of me,” and it can seem as if you didn’t give it your all.
BEST ANSWER: To cover both possible paths this question can take, your answer should state that you always try to do your best, and the best of your career is right now. Like an athlete at the top of his game, you are just hitting your career stride thanks to several factors. Then, recap those factors, highlighting your strongest qualifications.
Question 62 Why should I hire you from the outside when I could promote someone from within?
TRAPS: This question isn’t as aggressive as it sounds. It represents the interviewer’s own dilemma over this common problem. He’s probably leaning toward you already and for reassurance, wants to hear what you have to say on the matter.
BEST ANSWER: Help him see the qualifications that only you can offer.
Example: “In general, I think it’s a good policy to hire from within – to look outside probably means you’re not completely comfortable choosing someone from inside.
“Naturally, you want this department to be as strong as it possibly can be, so you want the strongest candidate. I feel that I can fill that bill because…(then recap your strongest qualifications that match up with his greatest needs).”
Question 63 Tell me something negative you’ve heard about our company…
TRAPS: This is a common fishing expedition to see what the industry grapevine may be saying about the company. But it’s also a trap because as an outsider, you never want to be the bearer of unflattering news or gossip about the firm. It can only hurt your chances and sidetrack the interviewer from getting sold on you.
BEST ANSWER: Just remember the rule – never be negative – and you’ll handle this one just fine.
Question 64 On a scale of one to ten, rate me as an interviewer.
TRAPS: Give a perfect “10,” and you’ll seem too easy to please. Give anything less than a perfect 10, and he could press you as to where you’re being critical, and that road leads downhill for you.
BEST ANSWER: Once again, never be negative. The interviewer will only resent criticism coming from you. This is the time to show your positivism.
However, don’t give a numerical rating. Simply praise whatever interview style he’s been using.
If he’s been tough, say “You have been thorough and tough-minded, the very qualities needed to conduct a good interview.”
If he’s been methodical, say, “You have been very methodical and analytical, and I’m sure that approach results in excellent hires for your firm.”
In other words, pay him a sincere compliment that he can believe because it’s anchored in the behavior you’ve just seen.

Good luck in your job search!