sample1 - 1 CSE 1030 Introduction to Computer Science II A...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 1030 Introduction to Computer Science II A Sample of Test 1 1 (a) In the declaration of an attribute, what does the keyword final denote? The attribute is a constant, that is, its value can only be set once. (b) In the declaration of an attribute, what does the keyword static denote? The attribute is associated with the class, not with each instance. Hence, there is only one such attribute. (c) In the body of a method, what does the keyword this denote? It refers to the object on which the method is invoked. It is the implicit parameter of the method. (d) In the header of a method, what does the keyword void denote? The method does not return a result. 2 Give three reasons why non-static attributes should be declared as private . It ensures that others cannot directly access the attributes and, hence, cannot assign them illegal values (for example, setting the age of a person to a negative number). It simplifies the API (private attributes are not part of the API). It allows the implementer to change the representation of the data (without having to change the API). 3 Consider the following snippet of client code. 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

sample1 - 1 CSE 1030 Introduction to Computer Science II A...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online