0% found this document useful (0 votes)
10 views1 page

Class Worksheet1 Java Aplus Key

The document is a worksheet key for a computer science class focused on a Java class named 'Folder'. It includes questions about constructors, instance variables, access modifiers, and method types related to the 'Folder' class. The answers provided indicate the number of constructors, instance variables, constant variables, accessor methods, and modifier methods, along with valid instantiation examples.

Uploaded by

pvadlamudirocks
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

Class Worksheet1 Java Aplus Key

The document is a worksheet key for a computer science class focused on a Java class named 'Folder'. It includes questions about constructors, instance variables, access modifiers, and method types related to the 'Folder' class. The answers provided indicate the number of constructors, instance variables, constant variables, accessor methods, and modifier methods, along with valid instantiation examples.

Uploaded by

pvadlamudirocks
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

A+ Computer Science Worksheet KEY

DIRECTIONS : Fill in the blank with the correct answer/output.

public class Folder


{
private int items;
private double value;

public Folder ( int it, double v ) {


items = it; value = v;
}

public void setItems(int it) { items = it; }


public void setValue(double v) { value = v; }

public int getItems() { return items; }


public double getValue() { return value; }

public String toString( ) { return "" + items + " " + value; }


}

1. How many constructor methods are there in Folder? _____1_________

2. How many instance variables are there in Folder? _____2_________

3. How many constant variables are there in Folder? _____0_________

4. How many accessor methods are there in Folder? _____3_________

5. How many modifier methods are there in Folder? _____2_________

6. Instance variables should always be defined with what access? ___private____

7. Constructor methods should always be defined with what access? __public____

8. Which of the following is a valid instantiation of Folder?

A. Folder a = new Folder;


B. Folder a = Folder();
C. Folder a = new Folder( 22, 11);
D. Folder a = new Folder( 3.2, 4.8);

9. Which of the following is a valid instantiation of Folder?

A. Folder a = new Folder;


B. Folder a = Folder(87);
C. Folder a = new Folder( 44 );
D. Folder a = new Folder( 34, 4.5);
10. What type of method is toString( ) ?

A. void B. return
C. new D. static

© A+ Computer Science – Worksheet – [Link]

You might also like