Create Software Components 

Using Java Level 2

 

 

Course Info

Scheme

Resources

Tutorials

Java Demos

Utilities

Links


 

    Multiple Choice Quiz 2

Pre-test Practice

There are 40 questions

(If you take this quiz on Blackboard you will be timed and receive a test score.  

This will be good practice for the real online test.)

Question 1.         

Comment lines are

(a)   included in the executable code

(b)   ignored by the linker

(c)   ignored by the compiler

(d)   compiled in the object code

Question 2.         

A run-time error is SOMETIMES caused by

(a)   incorrect logic

(b)   incorrect syntax

(c)   incorrect linking

(d)   division by zero

Question 3.         

Byte code is contained in a

(a)   java file

(b)   class file

(c)   html file

(d)   library file

Question 4.         

When a program is running the value of a constant

(a)   cannot be changed

(b)   cannot be used

(c)   is hidden

(d)   can be changed at any time

Question 5.         

When you want an object to refer to itself you use the word

(a)   super

(b)   obj

(c)   this

(d)   instance

Question 6.         

The scope of a local variable 

(a)   is unbounded 

(b)   global

(c)   is limited to the class

(d)   is limited to the method in which it is declared

Question 7.         

A program construct used for iteration/repetition is

(a)   if...else

(b)   method

(c)   while loop

(d)   a sequence

Question 8.         

What is the result of the the following expression

5+((2*(9+5))-4)/2

(a)   12.5

(b)   14.5

(c)   15

(d)   17

Question 9.         

An argument NOT passed by reference  passes

(a)   a global variable

(b)   a constant

(c)   a value

(d)   an address

Question 10.         

Which of the following is a loop construct that will always execute once?

(a)   for

(b)   switch

(c)   while

(d)   do while

Question 11.         

The methods of a class

(a)   define the actions to be performed

(b)   define the attributes of a class

(c)   cannot contain any variable declarations

(d)   cannot be called from inside a class

Question 12.         

The difference between an applet and a stand-alone application is that

(a)   an application requires a method called main() while an applet requires a method called init().  

(b)   an application requires a method called main() while an applet requires a method called paint().  

(c)   an application requires a method called main() while an applet requires a method called destroy().  

(d)   both an application and an applet require a method called main().

Question 13.         

Java applets are secure because

(a)   they do not run on the host computer but on the remote computer

(b)   they cannot read, write or delete host files

(c)   viruses cannot be introduced 

(d)   they run in read-only memory space

Question 14.         

Which one of the following is FALSE?

(a)   javac is the Java compiler

(b)   Java bytecode is stored in a .class file

(c)   Java source code is stored in a HTML file

(d)   java is the Java bytecode interpreter

Question 15.         

The new keyword

(a)   creates a class

(b)   creates runs a class method

(c)   creates an instance of a class

(d)   creates a new component class

Question 16.         

Which of the following expressions is valid for setting a font?

(a)   setFont(new Font ("Courier", plain, 12));

(b)   setFont(new Font ("Courier", bold, 12));

(c)   setFont(new Font ("Courier", Font.BOLD, 12));

(d)   setFontStyle(new Font ("Courier", Font.BOLD, 12));

Question 17.         

Which command executes a java application?

(a)   javac

(b)   javad

(c)   appletviewer

(d)   java 

Question 18.         

Which command executes a java applet?

(a)   javac

(b)   javad

(c)   appletviewer

(d)   java 

Question 19.         

Which command compiles source code to bytecode?

(a)   javac

(b)   javad

(c)   java

(d)   appletviewer

Question 20.         

A variable declared inside a method is called a

(a)   local variable

(b)   instance variable

(c)   class variable

(d)   constant

Question 21.         

Which one of the following methods does NOT specify a blue colour?

(a)   Color.blue

(b)   rgb(0,0,255)

(c)   rgb(0,255,0)

(d)   rgb(0,0,100)

Question 22.         

The drawString method is used for

(a)   drawing circles on an applet

(b)   sending text output to a text field

(c)   sending text output to a command prompt window

(d)   drawing text on an applet

Question 23.         

Which of the following is FALSE?

(a)   a class is a template

(b)   an instance of a class is an object

(c)   you can have one class with many instances

(d)   you can only have one instance of a class

Question 24.         

Examine the following method declaration.  

 public int myMethod (boolean b) 

Which of the following statements is FALSE

(a)   the term myMethod is the name of the method

(b)   the term int is the data type the method may return

(c)   b is a method parameter

(d)   the term boolean is the data type the method may return

Question 25.         

Which of the following is incorrect because it uses a Java  reserved word for a method, variable or class name?

(a)   int x;

(b)   public class boolean extends Applet

(c)   public void myboolean ()

(d)   boolean bool;

Question 26.         

The start() method is 

(a)   a required applet method

(b)   a required application method

(c)   used for initialising variables

(d)   part of an applet lifecycle

Question 27.         

The OR boolean operator is represented by 

(a)   &&

(b)   ||

(c)   ^

(d)   !

Question 28.         

A modal dialog box is always created using the

(a)   Dialog class

(b)   Windows class

(c)   JOptionPane class 

(d)   Frame class 

Question 29.         

Examine the following class header

public class AnotherClass extends JApplet implements ActionListener

Which of the following events will NOT be listened for? 

(a)   the clicking of a command button

(b)   the pressing down of a mouse button

(c)   the selecting of a radio button

(d)   the selection of a combo box item

Question 30.         

A frame is

(a)   a component

(b)   a window that can have a title bar

(c)   is used to create dialog boxes

(d)   a container for modal dialogs

Question 31.         

The layout manager that arranges components in rows and columns is called

(a)   FlowLayout

(b)   BorderLayout

(c)   GridLayout

(d)   BoxLayout

Question 32.         

The default layout manager for a panel is

(a)   FlowLayout

(b)   BorderLayout

(c)   GridLayout

(d)   BoxLayout

Question 33.         

What will be the result of the following expression?

String s1 = new String ("Hello");

s1.length()

(a)   true

(b)   false

(c)   5

(d)   7

Question 34.         

Which of the following Graphics methods is used for setting the color of a Graphics object?

(a)   setColor

(b)   setBackground

(c)   setForeground

(d)   SetColour

Question 35.         

Which of the following Graphics methods draws a vertical line?

(a)   drawLine(100,0,100,0)

(b)   drawLine(0,0,0,100)

(c)   drawLine(100,100,0,0)

(d)   drawLine(0,0,100,100)

Question 36.         

The AWT package contains

(a)   classes for handling input and output

(b)   Graphics classes

(c)   event handling classes

(d)   classes for components and containers

Question 37.         

Which method loads an image into an applet?

(a)   getImage

(b)   drawImage

(c)   getCodeBase

(d)   getDocumentBase

Question 38.         

Which method draws an image onto an applet?

(a)   getImage

(b)   drawImage

(c)   getCodeBase

(d)   getDocumentBase

Question 39.         

Which of the following correctly creates a new instance of an AWT panel?

(a)   Panel aNewPanel = new Panel ("hi");

(b)   JPanel aNewPanel = new JPanel (); 

(c)   Panel aNewPanel = Panel ();

(d)   Panel aNewPanel = new Panel ();

Question 40.         

Examine the following code

public class MyClass {

  char ch

  public void aMethod(int b) {

       for (int i = 0; i < 5; i++) 

             b = b + 1;

  }

}

Which of the following statement is TRUE?

(a)   the scope of i is limited to the for loop

(b)   the scope of i is limited to the method called aMethod

(c)   the scope of i is limited to the class

(d)   the scope of i is not limited

        

 

  Site Home 

Java Home   

  Forum  

Course Info

Welcome

Overview

Assessment

Qualification

Scheme of Work

Assignments

Resources

Information

Blackboard

Learning Center

Web Materials

Reading

Java Demos

Utilities

Links

Lecture Materials

Tutorials & Notes

Exercises

Activities

Quizzes

 

Site Home

Top

Unit Home

ADR 2002