PicturePicture
Questions

1-10
11-20
21-30

Answers

 

Java Certification
Sample Questions JDK1.0.2 - Questions 11-20
Java Certification Home - Tuesday, August 31, 1999

Question 11.

What is the target variable in an Event?

  1. the Object() where the event came from,
  2. the Object() where the event is destined for,
  3. what the Object() that generated the event was doing,
Question 12.

What is the statement to assign a unicode constant CODE with 0x30a0?

Question 13.

The following code resides in the source?

class StringTest {

public static void main( String [] agrs) {
  //
  // String comparing
  //
  String a,b;
  StringBuffer c,d;
  c = new StringBuffer("Hello");
  a = new String("Hello");
  b = a;     
  d = c;

  if ( <<<operator>>> ) { }

}
} //class

Which of the following statement return true for the <<>> line in StringTest.class?

  1. b.equals(a)

  2. b==a

  3. d==c

  4. d.equals(c)

Question 14.

Which are valid identifiers?

  1. %fred

  2. *fred

  3. thisfred

  4. 2fred

  5. fred

Question 15.

We have the following class X,

public class X {

   public void method();

}

<<<STATEMENTS>>>

Which of the following statement return true for the <<>> line in StringTest.class?

  1. abstract void method();

  2. class Y extends X { }

  3. package java.util;

  4. abstract class Z { }

Question 16.

Which code fragements would correctly identify the number of arguments passed via command line to a Java Application?

  1. int count = args.length;

  2. int count = 0; while args[count] !=null) count++;

  3. int count = 0;while (!(args[count].equals(""))) count++;

  4. int count = args.length - 1;

Question 17.

FilterOutputStream is the parent class for BufferedOutputStream, DataOutputStream and PrintStream. Which classes are valid argument for the constructor of a FilterOutputStream?

  1. InputStream

  2. OutputStream

  3. File

  4. RandomAccessFile

  5. StreamTokenizer

Question 18.

Given the following method body:

1:
2:{
3: if (unsafe()) {
4:   unsafe();
5: }
6: else {
7:   safe();
7: }
8:}

The method “unsafe” might throw an AWTException (which is not a subclass of RunTimeException). Which correctly completes the method of declaration when added at line one(1:)?

  1. public AWTException methodName()

  2. public void methodName()

  3. public void methodName() throws AWTException

  4. public void methodName() throw AWTException

  5. public void methodName() throws Exception

Question 19.

Given a TextField and is constructed like this:

TextField = new TextField(30);
  1. The displayed width is 30 columns.

  2. The displayed string can use multiple fonts.

  3. The user will be able to edit the character string.

  4. The displayed line will show exactly thirthy characters.

  5. The maximum of characters in a line will be thirthy.

Question 20.

Given this skeleton of a class currently under construction:

public class Example {
  int x, y;

  public Example( int a) {
    //lots of complex computation
    x=a;
   }

   public Example( int a, int b) {
     //do everythinf the same as single argument
     // including assignment x=a
     y=b;   
   }
}

What is the most concise way to code the “do everything the same as single argument?

To submit comments or suggestions about the Java Certification pages, please send mail to the writer.