CS160 - Midterm 1: Practice Test

¡Supera tus tareas y exámenes ahora con Quizwiz!

A developer designs a Student object that includes a name, address and gpa. This is an example of ___. A. data encapsulation B. data operations C. top-down software design D. abstraction

A

Programming Question (Look at #48) A. private void calcGPA( ) B. public void calcGPA( ) C. private calcGPA( ) D. private int calcGPA( )

A

Which is true? A. A class can implement only one interface B. A class can inherit from multiple classes C. An interface can implement multiple classes D. A class can implement multiple interfaces

UNSURE

Which is true? A. Private members can be accessed by a class user B. A mutator is also known as a getter method C. A mutator may change class fields D. An accessor is also known as a setter method

UNSURE

Which is true? A. A reference variable contains data rather than a memory address B. Thenewoperator is used to declare a reference C. A reference declaration and object creation can be combined in a single statement D. Three references can not refer to the same object

UNSURE

Programming Question (Look at #20) A. System.out.println("Student ID: " + getID( )); B. System.out.println("Student ID: "); C. System.out.println("Student ID: " + s.getID( )); D. System.out.println("Student ID: " + student.getID( ));

C

Programming Question (Look at #41) A. Firebird 2 B. Firebird C. Boat@f35a442b D. Syntax error

C

Programming Question (Look at #8) A. 00 01 02 B. 00 01 02 03 C. 00 01 10 11 D. 00 01 02 10 11 12

C

Programming Question (Look at #82) A. method driveForward() B. odometer is not defined C. method changeOdometer() D. all of class SimpleCar

C

Programming Question (Look at #86) A. 2, 5 B. 3, 5 C. 1, 3, 4 D. 1, 2, 3, 4, 5

C

Which is true about arrays and methods? A. Arrays cannot be passed to methods B. Passing an array to a method creates a copy of the array within the method C. An array is passed to a method as a reference D. A programmer must make a copy of an array before passing the array to a method

C

How many object references are declared? Car mustang = new Car(); Car prius; int miles; Truck tundra = new Truck(); A. 0 B. 1 C. 2 D. 3

D

How many objects of type Car are created? Car mustang = new Car(); Car prius; int miles; Truck tundra = new Truck(); A. 0 B. 1 C. 2 D. 3

D

Mustang is an object of type Car. Which statement invokes drive()? A. Car.drive(150); B. drive(135); C. mustang->drive(115); D. mustang.drive(145);

D

Programmers often use a powerful programming paradigm that consists of three key features — classes, inheritance, and abstract classes. What is the paradigm called? A. Modular programming B. Structured programming C. Universal Modeling Language D. Object-oriented programming

D

Programming Question (Look at #23) A. 20 B. 30 C. 100 D. 120

D

Programming Question (Look at #26) Coding Answers

D

Programming Question (Look at #37) A. setID(int pID) B. Plane() C. setID(int pID) D. getName()

D

Programming Question (Look at 15) A. String myName; B. public String myName; C. private myName; D. private String myName;

D

Which is true? Integer cost = 15; int quantity = 20; A. Variables cost and quantity store memory locations B. cost stores the value 15 C. quantity is a reference variable D. cost stores an object location

D

An ___ method shares the same name but a different number of parameters with another method in the same class. A. overridden B. inherited C. overloaded D. copied

C

Deriving properties of a base class is called _____. A. extension B. inheritance C. overloading D. implementation

B

Given classes Dog and Mammal. Which is true? A. Dog can be directly derived from Mammal and Canine B. Mammal is the base class C. Dog is the base class D. Mammal is derived from Dog

B

Programming Question (Look at #27) A. this = gpa B. this.gpa = gpa; C. double gpa = this.gpa; D. gpa = this.gpa;

B

Programming Question (Look at #53) Programming Answers

B

To quit, a user types 'q'. To continue, a user types any other key. Which expression evaluates to true if a user should continue? A. key == 'q' B. !(key == 'q') C. (!key) == 'q' D. key == (!'q')

B

A static field ___. A. is also called an instance variable B. is initialized in the constructor C. has global scope D. is accessed using an object name such as objectName.fieldName

C

A(n) ___ guides the design of subclasses but cannot be instantiated as an object. A. child class B. base class C. abstract class D. derived class

C

What are the possible values for (randGen.nextInt(9) + -4)? Assume a random number generator object named randGen exists. A. -4...4 B. -9...9 C. 0...4 D. 0...9

UNSURE

Programming Question (Look at #39) A. Has-a B. Is-a C. Contains-a D. There is no relationship between the two classes

UNSURE

Programming Questions (Look at #71) A. equal values and not equal references B. equal values and equal values C. not equal references and not equal references D. not equal references and equal values

UNSURE

The keyword this___. A. Implicitly refers to an object within instance methods B. Can not be used within a constructor C. Can not be used within instance methods D. Should be avoided when a field member and method parameter share the same name

UNSURE

If class Animal can only be accessed by classes defined in the same package as Animal. Which is the appropriate class definition? A. public class Animal B. class Animal C. private class Animal D. protected class Animal

UNSURE


Conjuntos de estudio relacionados

Chapter 1 Relative Positions/ Directional terms

View Set

Dichotomous Keys: Overview, Practice

View Set

Chapter 14: Positive and Negative Control

View Set

NU 325 - Musculoskeletal/ Ortho Exam

View Set

Module 8 Quiz - Relevant Fitness and Wellness Issues

View Set

US History Chapter 10-12 Study Guide questions

View Set

chapter 4 supply chain management

View Set