Create Software Components 

Using Java Level 2



Course Info




Java Demos




    Quiz 3

Classes, Applets & Applet Security

There are 20 questions

Question 1.         

The following code fragment 

public class helloWorldApp {

is not a correct class declaration because


(a)   It is declared as public

(b)   all class names should start with a capital letter

(c)   the name is too long

(d)   the class keyword should begin with a capital letter c 

Question 2.         

Which one of the following is FALSE?

(a)   a method is a block of code

(b)   a method is a way of writing code nicely

(c)   you use methods to send messages to objects

(d)   a class can have lots of methods 

Question 3.         

In Java new classes can be defined by extending existing classes. This is an example of:

(a)   interface

(b)   polymorphism

(c)   inheritance

(d)   encapsulation

Question 4.         

A Java class

(a)   has one and only one instance

(b)   can have as many instances as you like

(c)   is an object

(d)   contains objects

Question 5.         

A Java package

(a)   contains objects

(b)   is a group of pre-defined Java classes

(c)   contains source code

(d)   contains applets 

Question 6.         

The Java import statement

(a)   is used to include other required classes in your program

(b)   creates objects from classes

(c)   allows a Web browser to load applets

(d)   includes pre-defined methods in your program 

Question 7.         

In the following code fragment 

            public class HelloWorld extends Applet {

the keyword extends indicates


(a)   HelloWorld is going to be an applet

(b)   HelloWorld is a subclass of the Applet class

(c)   HelloWorld is a superclass of Applet class

(d)   Is not going to be an applet 

Question 8.         

Which one of the following is FALSE?

(a)   Java does not support inheritance

(b)   Java only supports single inheritance

(c)   all classes inherit from the Object class

(d)   subclasses can override inherited methods 

Question 9.         

We are defining a class called FunkyApplet.  Complete the statement below so our class is defined properly.

public class FunkyApplet__________________



Question 10.         

Which of the following methods is used to remove an applet from memory?

(a)   init()

(b)   main()

(c)   destroy()

(d)   stop()

Question 11.         

What is the purpose of the following code fragment?


void destroy()


...some code in here



(a)   A method used to remove an applet from memory

(b)   A method all user-defined classes must have

(c)   A place to declare variables

(d)   A required method in an application  

Question 12.         

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/write memory space

Question 13.         

Which one of the following is TRUE?  An applet running on a host computer can

(a)   read files

(b)   write files

(c)   delete files

(d)   list the contents of a folder

Question 14.         

Overriding a method means... 

(a)   removing the method from your class

(b)   adding a new method to your class

(c)   re-defining an inherited method

(d)   ensuring a subclass of your class cannot change the method

Question 15.         

Consider the following two classes 

public class ClassA {
    public void methodA (int i) {
    public void methodB (int i) {

public class ClassB extends ClassA {
    public static void methodA () {
    public void methodA (int i) {
    public void methodB (int i, int j) {
    public static void methodB () {

Which method of ClassB overrides a method from ClassA

(a)  the first method

(b)  the second method

(c)   the third method

(d)   the fourth method

Question 16 - 20.         

Consider the following lines 


public class ExampleClass {
    public static int x = 10; 
    public int y = 10; 

    public void doSomething () {

     System.out.println ( "a message");



How many class variables does ExampleClass  contain?



What is the name of the class variable?



How many instance variables does ExampleClass  contain?



What is the name of the instance variable?



What is the name of the method?





  Site Home 

Java Home   


Course Info





Scheme of Work





Learning Center

Web Materials


Java Demos



Lecture Materials

Tutorials & Notes





Site Home


Unit Home

ADR 2002