Sun Java Solaris Communities My SDN Account Join SDN
 
Quizzes

Building an Application

 

Quizzes Index


Test what you learned from the Building an Application tutorial series. Though this quiz covers the first two parts, the questions focus on basic Java programming fundamentals, aimed at beginning to intermediate developers.

Choose the most appropriate choice for each question below.

  1. A class is . . .
     A. an object in memory.
     B. the definition of an object, specifying methods and fields.
     C. a special constructor.
     D. None of the above.


  2. Fields define state, methods define function or change, and constructors define . . .
     A. how an object should be built as an instance of the class.
     B. properties for garbage collection.
     C. a static method to be called at runtime.
     D. All of the above.


  3. An import statement . . .
     A. includes the packages or classes you need for your application
     B. tells the compiler to move the imported class into your package.
     C. provides a shortcut around typing out the fully qualified name of a class or package.
     D. None of the above


  4. What purpose do access modifers serve?
     A. They designate whether or not each object has its own copy, or if each object shares a value.
     B. They specifiy read and write permissions.
     C. They tell the compiler if other packages or classes have access to the variable or method they are modifying.
     D. None of the above.


  5. If you create a subclass of JFrame, the subclass inherits methods from JFrame and any class that JFrame inherits from.
     A. True
     B. False


  6. To call an inherited method on, or send a message to, an object, such as making the foreground of a label blue, you . . .
     A. instantiate the class that defines the method using the keyword new then call the method by name:
        JLabel label = new JLabel("A label"):
        Component newlabel = new Component(label);
        Component.newlabel.setForeground(Color.blue);
              
     B. use the dot operator, the object reference identifier, and the method name:
        JLabel label = new JLabel("A label");
        label.setForeground(Color.blue);
               
     C. redefine the method you want to use.
     D. None of the above.


  7. The main method for an application should be . . .
     A. in every class of the application's package.
     B. in the last class instantiated.
     C. in the class intended to launch the application.
     D. None of the above.


  8. If your subclass extends JFrame, how do you call the JFrame constructor?
     A. super("A Sample Application");
     B. JFrame("A Sample Application");
     C. this("A Sample Application");
     D. None of the above.


  9. A JPanel is an object, a container that . . .
     A. can only hold buttons and toolbars.
     B. creates a frame object for an application.
     C. can hold other components, containers, and has a layout manager associated with it.
     D. None of the above.


  10. The border layout manager allows a maximum of five objects to be added to a panel. You can increase the number of objects added by . . .
     A. adding another panel to each region.
     B. overriding the add method.
     C. None of the above.


  11. A JLabel is a simple component that . . .
     A. provides a place for users to enter input.
     B. holds layout managers.
     C. holds text and images.
     D. None of the above.


  12. The regions of the BorderLayout class are written with all uppercase characters because . . .
     A. these fields are private.
     B. the fields need to match a geographical map.
     C. these fields are constants and conform to naming conventions.
     D. None of the above.