Quiz


1.  

What is an instance variable?

an instance variable is an attribute of a class.

2.  

How do you determine the size of a class?

you determine the class size by adding the size of all its attributes.

3.  

Explain the steps necessary to create an instance of a class.

you declare an instance of a class by first reserving memory for the class using the new operator followed by the constructor of the class ( new registrationform() ). next, declare a reference to the class and give that reference a name ( registrationform myregistrationform ). finally, assign a reference to the memory reserved for the class to the reference using an assignment statement.

4.  

How do you declare an instance variable?

an instance variable is declared by specifying the data type of the variable, followed by the variable name, and ending with a semicolon within the body of a class definition.

5.  

What is a data type?

a data type is a keyword that tells the computer the kind of data you want to store in a memory location.

6.  

Explain the parts of a method definition.

a method definition consists of the name of a method, an argument list (if any), the data type of the value returned by the method, and the method body.

7.  

What is the difference between an argument list and a parameter list?

although some programmers consider an argument list and a parameter list to be the same thing, other programmers consider a parameter list to be values passed to a method when the method is called, and they consider an argument list to be values defined within the method definition that receive values passed to the method.

8.  

Explain the steps for calling a member method.

a member method is called by first declaring an instance of a class and then using the name of the instance followed by the dot operator and the name of the method- myinstance.mymethod() , for example.

9.  

What is a constructor and how do you define one?

a constructor is a method of a class that is called automatically when an instance of a class is declared. a constructor is defined in the class and must have the same name as the class name. a class can have multiple constructors, each with a different argument list. the argument list is traditionally used with the constructor to initialize instance variables of the class.

10.  

How do you access an instance variable from within your program?

an instance variable is accessed by first declaring an instance of a class and then using the name of the instance followed by the dot operator and the name of the variable- myinstance.myvariable , for example.

Answers

1.  

An instance variable is an attribute of a class.

2.  

You determine the class size by adding the size of all its attributes.

3.  

You declare an instance of a class by first reserving memory for the class using the new operator followed by the constructor of the class ( new RegistrationForm() ). Next, declare a reference to the class and give that reference a name ( RegistrationForm myRegistrationform ). Finally, assign a reference to the memory reserved for the class to the reference using an assignment statement.

4.  

An instance variable is declared by specifying the data type of the variable, followed by the variable name, and ending with a semicolon within the body of a class definition.

5.  

A data type is a keyword that tells the computer the kind of data you want to store in a memory location.

6.  

A method definition consists of the name of a method, an argument list (if any), the data type of the value returned by the method, and the method body.

7.  

Although some programmers consider an argument list and a parameter list to be the same thing, other programmers consider a parameter list to be values passed to a method when the method is called, and they consider an argument list to be values defined within the method definition that receive values passed to the method.

8.  

A member method is called by first declaring an instance of a class and then using the name of the instance followed by the dot operator and the name of the method ” myInstance.myMethod() , for example.

9.  

A constructor is a method of a class that is called automatically when an instance of a class is declared. A constructor is defined in the class and must have the same name as the class name. A class can have multiple constructors, each with a different argument list. The argument list is traditionally used with the constructor to initialize instance variables of the class.

10.  

An instance variable is accessed by first declaring an instance of a class and then using the name of the instance followed by the dot operator and the name of the variable ” myInstance.myVariable , for example.




OOP Demystified
OOP Demystified
ISBN: 0072253630
EAN: 2147483647
Year: 2006
Pages: 130

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net