1. Q .
A. Line 35 will not compile.
B. Line 36 will not compile.
C. Line 37 will not compile.
D. Line 38 will not compile.
2. Q .
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)
3. Q . Which two code fragments correctly create and initialize a
static array of intelements?
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; }
4. Q . public static void main(String[] args) {
String str = "null"; if (str == null) {
System.out.println("null");}
else (str.length() == 0) {
System.out.println("zero");}
else { System.out.println("some");}}
Output is : -
A. null
B. zero
C. some
D. Compilation fails.
E. An exception is thrown at runtime.
5. Q . public interface Status {
12. /* insert code here */ int MY_VALUE = 10;
13. }
Which three are valid on line 12?Output is : -
A. final
B. static
C. native
D. public
E. private
F. abstract
G. protected
6. Q . 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:
private int itemId;
private String name;
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)
7. Q . package animals.mammals;
public class GrizzlyBear extends Bear { void hunt() { Salmon s = findSalmon();
s.consume(); } } and another file, Salmon.java:
package animals.fish;
public class Salmon extends Fish { void consume() { /* do stuff */ } }
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?
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
8. Q . Which are valid declarations?
A. int $x;
B . int 123;
C. int _123;
D. int #dim;
E. int %percent;
F. int *divide;
G. int central_sales_region_Summer_2005_gross_sales;
Identifires must be start with $ , _ or letter.
9. Q . class Voop {
public static void main(String[] args) {
doStuff(1);
doStuff(1,2);
}
// insert code here Line 1
}
inserted independently at line 6, will compile?
A. static void doStuff(int... doArgs) { }
B . static void doStuff(int[] doArgs) { }
C. static void doStuff(int doArgs...) { }
D. static void doStuff(int... doArgs, int y) { }
E. static void doStuff(int x, int... doArgs) { }
10. Q . Which are legal declarations?
A. short x [];
B . short [] y;
C. short[5] x2;
D. short z2 [5];
E. short [] z [] [];
F. short [] y2 = [5];
C , D , F is incorrect because we cant specify the size of an array on the time
of declaration. F uses invalid syntax
11. Q . Which method names follow the JavaBeans standard?
A. addSize
B . getCust
C. deleteRep
D. isColorado
E. putDimensions