Home | Articles

Tech Tips Programming Quiz

Take a few minutes to test your general knowledge of Java programming. These questions are compiled from the JDC Tech Tips. If you do not know an answer, take a guess.

1. Why are Java ARchive (JAR) files important?

Option Description
 A. They are necessary for installation and configuration.
 B. They bundle .class files and optimize applet loading.
 C. They prevent security leaks.
 D. They save coding time.

2. Which code segment ensures garbage collection happens in a timely manner?

Option Description
 A.
          public Object pop()
          {
            Object p = stk[stkp];
            stk[stkp--] = null;
            return p;
           }
 B.
          public class Stack {
            private static final int MAXLEN = 10;
            private Object stk[] = new Object[MAXLEN];
            private int stkp = -1;

            public void push(Object p) {stk[++stkp] = p;}

            public Object pop() {return stk[stkp--];}
          }

3. What is the purpose of the toolkit in the Abstract Window Toolkit (AWT)?

Option Description
 A. To repair broken frames.
 B. To create custom components.
 C. An interface between the abstract window layer and windowing implementation.
 D. To facilitate multicolor printing.

4. What is an interface class?

Option Description
 A. A collection of method declarations and constant values.
  B. An abstract base class.
 C. A way to get multiple inheritance.
 D. A way to inherit variables and method implementations.

5. Vertical and horizontal scroll bar increments are how many units by default?

Option Description
 A. 12.5 units.
 B. 100 units.
 C. 5 units.
 D. 1 unit.

6. Reflection (introspection) is querying a class about its properties, and operating on methods and fields by the name for a given object instance. Why is reflection possible in the Java language?

Option Description
 A. Late binding.
 B. Early binding.
 C. Java developers are very introspective people.
 D. Reflection is possible in all languages.

7. The StringBuffer class supports what type of strings?

Option Description
 A. Mutable (changeable).
 B. Immutable (unchangeable).
 C. Violins and cellos.
 D. Rotated and scaled.

8. Why does an Assert class that checks program assertions need several implementations of its assert method?

Option Description
 A. The Java language has loose type checking.
 B. The Java language has tight type checking.
 C. To keep tabs on garbage collection.
 D. You never know how many you need, so you should always cover the most obvious cases.

9. What is serialization?

Option Description
 A. Compiling several class files in series.
 B. Selecting several items with a series of rapid mouse clicks.
 C. Assigning a special number to an application.
 D. A way to convert objects into a stream of bytes.

10. What is javap?

Option Description
 A. A tool for making classes public.
 B. The Java print command.
 C. A tool for generating information on .class files
 D. The Java profiler.

© 1994-2005 Sun Microsystems, Inc.