- Answers to Prelim 1 CS100J Spring 2006 David Gries djg17 4(a An instance is a President public class President extends Politician int months

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Answers to Prelim 1. CS100J, Spring 2006 David Gries djg17 1. (a) A non-static method is a component of every instance of the class. A static method does not go in each instance; there is one copy of it, in the class’s file drawer. (b) There are 4 kinds of variable: non-static variable (field) defined in a class, static variable, parameter, and local variable. The scope of non-static variable is the body of all non-static methods in the class. The scope of a static variable is the body of all methods defined in the class (static or non-static). The scope of a parameter is body of the method for which it is a parameter. The scope of a local variable begins at its declaration and ends at the end of the block in which it is declared. (c) A parameter is a variable that is declared in the header of a method. (d) false , “error”, false . 2. 3. (a) The superclass of Politician is Object. (b) toString()
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/01/2008 for the course CS 100 taught by Professor Fan/vanloan during the Fall '07 term at Cornell University (Engineering School).

Ask a homework question - tutors are online