Quiz


1.  

What is a stack?

a stack is the way you groups things together by placing one thing on top of another and then removing them one at a time from the top of the stack.

2.  

What is the purpose of the push() member method?

the push() member method places a value onto the top of a stack.

3.  

What is the purpose of the pop() member method?

the pop() member method removes the value from the top of a stack, which is then returned by the pop() member method to the statement that calls the pop() member method.

4.  

What is the purpose of the isFull() member method?

the isfull() member method determines if there is room for one more value on the stack.

5.  

What is the purpose of the isEmpty() member method?

the isempty() member method determines if a value is at the top of the stack and is called before an attempt is made to remove the value.

6.  

What kind of value is assigned to the top attribute?

the value at the top attribute is an index.

7.  

Why is the top attribute initialized to “1?

the top attribute is initialized to 1 because when the attribute is incremented by the push() member method, the new value of the top attribute is zero, which is the index of the first element of the array used to create the stack.

8.  

What is the purpose of the keyword private ?

the keyword private means that the attribute or member method is accessible only by a member method. the instance of the class cannot directly access a private member of the class.

9.  

What is the purpose of the keyword public ?

the keyword public means that the attribute or member method is accessible to member methods and from the instance of the class.

10.  

What is the difference between a constructor and a destructor?

a constructor is a member method of a class that is called when an instance of the class is declared. a destructor is a member method of a class that is called when the instance of the class falls out of scope.

Answers

1.  

A stack is the way you groups things together by placing one thing on top of another and then removing them one at a time from the top of the stack.

2.  

The push() member method places a value onto the top of a stack.

3.  

The pop() member method removes the value from the top of a stack, which is then returned by the pop() member method to the statement that calls the pop() member method.

4.  

The isFull() member method determines if there is room for one more value on the stack.

5.  

The isEmpty() member method determines if a value is at the top of the stack and is called before an attempt is made to remove the value.

6.  

The value at the top attribute is an index.

7.  

The top attribute is initialized to “1 because when the attribute is incremented by the push() member method, the new value of the top attribute is zero, which is the index of the first element of the array used to create the stack.

8.  

The keyword private means that the attribute or member method is accessible only by a member method. The instance of the class cannot directly access a private member of the class.

9.  

The keyword public means that the attribute or member method is accessible to member methods and from the instance of the class.

10.  

A constructor is a member method of a class that is called when an instance of the class is declared. A destructor is a member method of a class that is called when the instance of the class falls out of scope.




Data Structures Demystified
Data Structures Demystified (Demystified)
ISBN: 0072253592
EAN: 2147483647
Year: 2006
Pages: 90

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