Question 1: String manipulation |
|
From: Sjaak de Mul (15 Mar 1999) / 1.x | |
Given the following declaration: | |
String s = " Example "; |
|
Which are legal code? Select the correct answers: |
A.
|
s >>>= 3; | |
B.
|
s[3] = "x"; | |
C.
|
int I = s.length(); | |
D.
|
String t = "For " + s; | |
E.
|
String shortS = s.trim(); |
Question 2:   |
|
From: Sjaak de Mul (15 Mar 1999) / Java 2 | |
Which contains objects without ordering, duplication and any lookup/retrieval mechanism? | |
Select best answer: |
A.
|
Map | |
B.
|
Set | |
C.
|
List | |
D.
|
Collections | |
E.
|
Enumeration |
Question 3: Declarations |
|
From: Sjaak de Mul (15 Mar 1999) / 1.1.x | |
Which statements declare a variable a which is suitable for refering to an array of 50 String objects? |
A.
|
char a[][]; | |
B.
|
String a[]; | |
C.
|
String [] a; | |
D.
|
Object a[50]; | |
E.
|
String a[50]; |
Question 4: Declarations |
|
From: Sjaak de Mul (15 Mar 1999) / 1.1.x | |
Code sample: | |
Public class Outer { public class Inner { public Inner() { } public static void main() { <<statement>>; } } |
|
What is the correct way to instantiate the inner class in the main of Outer? |
Question 5: Language |
|
From: Richard Yaol (15 Mar 1999) / 1.x | |
What modifier should be applied to a method for the lock of the object 'this' to be obtained prior to obtain of the method body? |
Question 6: EventHandling |
|
From: Richard Yaol (19 Nov 1999) / 1.x | |
What is the argument type for all methods defined in the interface MouseListener? |
Question 7: Language |
|
From: Richard Yaol (19 Nov 1999) / 1.x | |
Which cannot be used in declaring and initializing an automatic (method call) variable? |
A.
|
initialized arrays (such as {"Hello","Goodbye"}) | |
B.
|
final | |
C.
|
public | |
D.
|
constant of non-primitive type | |
E.
|
inner class from other scopes |
Question 8: EventHandling |
|
From: Richard Yaol (19 Nov 1999) / 1,x | |
What is true of the listeners? |
A.
|
the return type is boolean | |
B.
|
most components allow multiple listeners to be added. | |
C.
|
a copy of the original event is passed into a listener method |
Question 9: EventHandling |
|
From: Richard Yaol (15 Nov 1999) / 1.x | |
What is the return type of all AWT listener method? |
Question 10: EventHandling |
|
From: Richard Yaol (15 Nov 1999) / 1.x | |
What might form part of correct inner class declaration and installation? |
A.
|
new simpleInterface(){} | |
B.
|
new complexInterface(x) {} | |
C.
|
private final abstract class c | |
D.
|
MyClass extends OtherClass | |
E.
|
new MyClass() extends OtherClass{} |
Question 11: Language |
|
From: Savariyar Innasimuthu Savariyar Innasimuthu (09 Feb 2000) / 1.x | |
Find out all java keywords |
A.
|
extends | |
B.
|
sizeof | |
C.
|
implements | |
D.
|
TRUE | |
E.
|
NULL |
Question 12: Objectreferences |
|
From: Savariyar Innasimuthu (09 Feb 2000) / 1.x | |
What does the following code produce? | |
public class test02 { public static void main(String args[]) { Integer i1 = new Integer(9); Integer i2 = new Integer(9); Long l1 = new Long(9L); if ( i1 == i2) System.out.println("Test1"); if ( i1.equals(i2)) System.out.println( " Test2"); if ( i1.equals(new Integer(9)) ) System.out.println("Test3"); } } |
A.
|
Test1 | |
B.
|
Test2,Test3 | |
C.
|
Test1,Test2 | |
D.
|
Test2,Test3 |
Question 13: Runtime errors |
|
From: Savariyar Innasimuthu (09 Feb 2000) / 1.x | |
Here is pseudo code: | |
1 String s = null; 2 if ( s != null & s.length() > 0) 3 System.out.println("s != null & s.length() > 0"); 4 if ( s != null && s.length() > 0) 5 System.out.println("s != null & s.length() > 0"); 6 if ( s != null || s.length() > 0) 7 System.out.println("s != null & s.length() > 0"); 8 if ( s != null | s.length() > 0) 9 System.out.println("s != null | s.length() > 0"); |
|
Which of the following lines throwing null pointer exception |
A.
|
2,4 | |
B.
|
6,8 | |
C.
|
2,4,6,8 | |
D.
|
2,6,8 |
Question 14: Language |
|
From: Vishnu Vardhan (12 Feb 2000) / 1.x | |
What is the range of an integer? |
A.
|
-2^15 to 2^15-1 | |
B.
|
0 to 2^15 | |
C.
|
-2^31 to 2^31-1 | |
D.
|
0 to 2^31 |
Question 15: Language |
|
From: Vishnu Vardhan (12 Feb 2000) / 1.x | |
Suppose if you dont want allow a method to be overridden and class will be allowed to be subclassed. What is the right keyword? |
Question 16: Language |
|
From: Vishnu Vardhan (12 Feb 2000) / 1.x | |
What is the method used to schedule a thread for execution? |
Question 17: Declarations |
|
From: Vishnu Vardhan (12 Feb 2000) / 1.x | |
We have the following code? | |
public class Test { String animals = null; public static void main(String []args) { <<statement>> } } |
|
java Test cat horse |
|
How can you assign 'cat' to the animals vairable? |
A.
|
animals = args(0); | |
B.
|
String animals = args(0); | |
C.
|
animals =args(1); | |
D.
|
String animals = args(1); |
Question 18: Language |
|
From: Vishnu Vardhan (12 Feb 2000) / 1.x | |
Which identifiers are valid? |
A.
|
$Fred | |
B.
|
this | |
C.
|
_this | |
D.
|
instance | |
E.
|
2for | |
F.
|
for2 | |
G.
|
%var |
Question 19: Language |
|
From: Vishnu Vardhan (12 Feb 2000) / 1.x | |
We have the following code: | |
if (a >4) System.out.println("test1"); else if (a >9) System.out.println("test2"); else System.out.println("test3"); |
|
What will print 'test 2'? |
A.
|
less than 0 | |
B.
|
less than 4 | |
C.
|
between 4 and 9 | |
D.
|
greater than 9 | |
E.
|
none |
Question 20: Language |
|
From: Vishnu Vardhan (12 Feb 2000) / 1.x | |
outer: for( int i_=1; i<3 ;i++) { inner : for ( j= 1;j<3;j++) { if (j==2) continue outer: System.out.prinltn("i= " + i ",j = " + j) } } |
|
What will the code piece print? |
A.
|
1,1 | |
B.
|
1,2 | |
C.
|
2,1 | |
D.
|
2,2 | |
E.
|
3,1 | |
F.
|
3,2 |
Question 21: Declarations |
|
From: Vishnu Vardhan (12 Feb 2000) / 1.x | |
Given the following function? | |
void withinsomefunc() { if (functionfailed()) //to confuse --given it as failed but returns true { // some code <<statement>> } } |
|
If functionfailed is true it will throws someexception? What are valid changes to the code? (SomeException is not | |
Select be answer(s)? |
A.
|
throws new SomeException() | |
B.
|
throw new SomeException(); | |
C.
|
return new SomeException(); | |
D.
|
void withinsomefunc() throw SomeException { | |
E.
|
void withinsomefunc() throw Exception { | |
F.
|
void withinsomefunc() throws SomeException { | |
G.
|
void withinsomefunc() throws Exception { | |
H.
|
throw new Exception(); |
Question 22: Language |
|
From: Vishnu Vardhan (12 Feb 2000) / 1.x | |
void func() { String str = null; try { if (str.length() == 0) { System.out.print("The"); } System.out.print(" Cow"); } catch (Exception e) { System.out.print(" and"); System.exit(0); } finally { System.out.print(" Chicken"); } System.out.println(" show"); } |
|
What will be printed? Select correct answers: |
A.
|
The | |
B.
|
Cow | |
C.
|
and | |
D.
|
Chicken | |
E.
|
show |
Question 23: Declarations |
|
From: Vishnu Vardhan (12 Feb 2000) / 1.x | |
some design issues: The following description applies to a class: given someclassname behaves as somesuperclassname and it has some fields etc it is accessed in other files. No other class can behave as this class. | |
extends public int class someclassname somesuperclass implements File extends Class final |
|
What is the right syntax declaration of this class? |
Question 24: Declarations |
|
From: Vishnu Vardhan (12 Feb 2000) / 1.x | |
given Answer class behaves like some a File it has a Vector , a color ,some boolean variable? | |
import public private Vector Serializable File Color extends boolean implements |
|
What is the correct declaration? |
Question 25: Language |
|
From: Vishnu Vardhan (12 Feb 2000) / 1.x | |
Which of the following are FilterInputStreams? |
A.
|
InputStream | |
B.
|
DataInputStream | |
C.
|
OutputStream | |
D.
|
FileInputStream | |
E.
|
LineNumberInputStream | |
F.
|
ByteArrayInputStream | |
G.
|
StringBufferInputStream | |
H.
|
BufferedInputStream |
Question 26: Language |
|
From: Vishnu Vardhan (12 Feb 2000) / 1.x | |
You have the following code: | |
public class Test { int c = 0; public Test(int a, int b) { c = b*(a/12); } public Test(int a){ c = a/12; } public Test(int a, int b, float c) { <<statement>> } } |
|
What statement should be entered to initialize c? |
Question 27: Runtime errors |
|
From: Vishnu Vardhan (12 Feb 2000) / 1.x | |
Which of the following may throw an exception? | |
1 if ((s !=null) | ( i =s.length())) 2 if ((s ==null) | ( i =s.length())) 3 if ((s !=null) || ( i =s.length())) 4 if ((s ==null) || ( i =s.length())) |
|
Select all best answers? |
A.
|
1 | |
B.
|
2 | |
C.
|
3 | |
D.
|
4 |
Question 28: Declarations |
|
From: Vishnu Vardhan (12 Feb 2000) / 1.x | |
How do you represent 7 as an octal number? |
Question 29: Language |
|
From: Kohli, Hardeep (12 Feb 2000) / 1.x | |
Choose the correct sentence for fully encapsulated class: |
A.
|
All member variables are private | |
B.
|
All member variables declared private and provide public accessor methods for each variable. | |
C.
|
Declare all variables without any access modifier. | |
D.
|
Make all the methods private |
Question 30: Declarations |
|
From: Kohli, Hardeep (12 Feb 2000) / 1.x | |
Choose correct declarations of two dimensional String array |
A.
|
String[][] a = String[20][20] | |
B.
|
String[][] a = new String[20,20] | |
C.
|
String[][] a = new String[20][20] | |
D.
|
String a[][] = new String[20][20] | |
E.
|
String[] a[] = new String[20]20] |
{loading}{scripting-1}{scripting}
The Notes
More is added to the list, but what I realy need is your help to keep
this information up-to-date and may be it needs correcting in one way
or the other. Please feel free to help me complement these question
and answers drop us an email at this
address. (C) 1998-2001, BMC88 - Personal WebSite of Java Certification
Exams
Part I
Part II
Part III
Part IV
Answers{submenus}