Docsity

Second Test for Introduction to Computing and Programming | CSCI 1301, Exams of Computer Science

Partial preview of the text

Download Second Test for Introduction to Computing and Programming | CSCI 1301 and more Exams Computer Science in PDF only on Docsity!

Test 2 CSCI 1301, Spring 2011 Computer Science Department, University of Georgia Administered April 14th, 2011 - 2:00 PM to 3:15 PM

Name:

UGAID:

Questions 1-10 (5pts each): Question 11-15 (10pts each): Question 16 (10pts):

  1. Within a method, the keyword is used to access the object’s other methods and variables.
  2. Within a constructor, the keyword is used to call the corresponding construc- tor from the class that is being extended.
  3. A variable or method can be accessed without creating an instance of the class.
  4. The elements of an array can be accessed through the array’s indexes, and the indexes start at.
  5. is the ability to substitute one object for another, such as assigning a Motorcyle object to a Vehicle datatype.
  6. A constructor has no parameters, while an con- structor does.
  7. In Java, you classes and interfaces.
  8. An is an instance of a class, and the variables and methods are of the object because they belong to the object.
  9. Within a class, if a method does not return anything then its return type is. If a method can only be accessed from within instances of the class then it is a method.
  10. Java you, but I do hope you understand that its strict, strongly typed behav- ior will help you better understand other programming languages, and learning your next programming language isn’t going to take nearly as long. You eventually get to the point where you can pick up a new language within a week.
  1. Given the array numbers, accessing numbers[6] will return the element of the array. If numbers.length is 3, then accessing numbers[6] will the program (try to minimize the vulgarity here).
  2. Create the class Apple that extends the class Food and implements the class Size. The class should only contain a default constructor and a single, publicly available boolean constant named isApple that the default constructor initializes to true. You can assume that Size is an empty interface and both Food and Size are written for you.
  1. Given the interface Shape below, write the class Circle. Remember that the object’s instance variables are not set so a constructor will be required.

public interface Shape{ public int area(); // calculates area of shape public int perimeter(); // calculates perimeter of shape }

public _______ Circle ________________ Shape{ private int x, y, radius;