Sun Java Solaris Communities My SDN Account Join SDN
 
Quizzes

Core Java Technologies Tech Tips Quiz

 

Quizzes Index

October 2002

Duke Test your knowledge of Java programming language topics covered in some recent Core Java Technologies Tech Tips (formerly, JDC Tech Tips), an electronic mailing containing tips, techniques, and sample code on various topics of interest to developers using the Java platform.

  1. Which of the following timer classes schedules tasks for execution in a background thread?
     A. javax.swing.Timer
     B. java.util.Timer


  2. Why should you specify the -source 1.4 flag when you compile the following program?
    public class AssertDemo {
       public static void main(String args[]) {
          boolean enabled = false;
                             
          assert enabled = true;
                             
          System.out.println("Assertions are " +
             (enabled ? "enabled" : "disabled"));
       }
    }
    


     A. The compiler will recognize assert as a keyword.
     B. The compiler will enable an assertion trace.
     C. The compiler will mark assertions for removal if the program is run in a resource constrained device.
     D. The program will run faster.


  3. Is a zero-length array valid in the Java programming language?
     A. Yes
     B. No


  4. What is a regular expression?
     A. An algorithm that evaluates a regular value.
     B. An expression that does not include special variables or operators.
     C. An expression that is used recursively.
     D. A pattern of characters that is often used in pattern matching.


  5. How do you display text in multiple colors or styles in a JTextArea component?
     A. Use setter methods, such as setSelectedTextColor to set multiple colors or styles in the JTextArea component.
     B. Use the createDefaultModel method to create a default model that provides for multiple styles and colors in the JTextArea component.
     C. Specify an attribute set for the JTextArea component.
     D. You can't display multiple colors or styles in a JTextArea component.


  6. What does the following program display?

    public class OverDemo1 {         
        // overload methodA between short/int
                             
        static void methodA(short s) {
        System.out.println(
             "methodA(short) called");
        }
        static void methodA(int i) {
        System.out.println("methodA(int) called");
        }
                             
        // overload methodB between float/double
                             
        static void methodB(float f) {
        System.out.println(
             "methodB(float) called");
        }
        static void methodB(double d) {
        System.out.println(
             "methodB(double) called");
        }
                             
        public static void main(String args[]) {
                             
        // call methodA with char argument
                             
        methodA('a');
                             
        // call methodB with int argument
                             
        methodB(Integer.MAX_VALUE);
        }
    }
    


     A.
      methodB(float) called
      methodA(int) called
      
     B
      methodA(short) called
      methodB(double) called
      
     C.
      methodA(int) called
      methodB(float) called
      
     D
      methodB(double) called
      methodA(int) called
      


  7. What Java API implements Porter-Duff rules?
     A. Java Media Framework (JMF)
     B. Java 2D
     C. Java 3D
     D. None of the above


  8. Is it possible to programmatically access the individual elements of a stack traceback?
     A. Yes
     B. No


  9. Why is it often a good idea to provide a readResolve method for a serializable class?
     A. The method improves serialization/deserialization efficiency
     B. It's mandatory when serializing/deserializing instance-controlled classes
     C. You can implement the method to resolve anomalies resulting from deserialization
     D. All of the above


  10. Which of the following methods return the symbol for a currency?
     A. java.math.Currency.getSymbol
     B. java.util.Currency.getSymbol
     C. java.lang.Object.getSymbol
     D. java.util.Locale.getSymbol


1 As used on this web site, the terms "Java virtual machine" or "JVM" mean a virtual machine for the Java platform.