Chapter 4 Study Guide

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Define a class that will represent a car.

public class Car

A class' constructor usually defines...

how an object is initialised

If a method does not have a return statement, then...

it must be a void method

Instance data for a Java class...

may be primitive types or objects

Having multiple class methods of the same name where each method has a different number of or type of parameters is known as...

method overloading

The behaviour of an object is defined by the object's...

methods

What reserved words in Java is used to create an instance of a class?

new

The relationship between a class and an object is best described as...

objects are instances of class

If "Swapper s = new Swapper(0, "hello", 0);" is followed by "s.toString();", what value is returned from "s.toString()"?

"00"

If "Swapper r = new Swapper(5, "no", 10);", then "r.swap()" returns what?

"no"

T/F: Every class definition must include a constructor.

False

What is a mutator method?

A method that modifies a value

T/F: Formal parameters are those that appear in the method call and actual parameters are those that appear in the method header.

False

T/F: Java methods can return more than one item if they are modified with the reserved word continue, as in public continue int foo( ) { ... }

False

T/F: Java methods can return only primitive types.

False

"Die d = new Die(10);" results in...

Die d having numFaces = 10 and faceValue = 1

T/F: All Java classes must contain a main method which is the first method executed when the Java class is called upon.

False

In order to preserve encapsulation of an object, we would NOT do what?

Make the class final

What could be used to instantiate a new Student s1?

Student s1 = new Student("Jane Doe", "Computer Science", 3.333, 33);

"Due d = new Die(10, 0);" results in...

Syntax error

Which of the following criticisms is valid about the Swapper class?

The instance data z is visible outside of Swapper

T/F: A method defined in a class can access the class' instance data without needing to pass them as parameters or declare them as local variables.

True

T/F: Defining formal parameters requires including each parameters type.

True

T/F: The following method header definition will result in a syntax error: public void aMethod( );

True

T/F: The interface of a class is based on those data instances and methods that are declared public.

True

T/F: While multiple objects of the same class can exist, there is only one version of the class.

True

An example of passing a message to a String where the message has a String parameter occurs in what?

equals

Consider a method defined with the header: "public void foo(int a, int b)". Which of the following method calls is legal?

foo(0/1, 2*3);

A method that updates the Student's number of credit hours by receiving a number of credit hours and ad these to the Student's current hours is defined as...

public void updateHours(int moreHours) { hours += moreHours; }

A method that will compute and return the student's class rank is defined as...

s1.getClassRank();


Set pelajaran terkait

Intermediate Accounting II - Test 2 (Chapter 16, 17 & 18)

View Set

Chapter 8 Lab questions phlebotomy

View Set

Nutrition Practice Questions Chapters 11, 12, 13

View Set

UNIT 2 QUIZ 1: (Benefits of Proper Nutrition, Carbohydrates, & Vitamins)

View Set

DECA Entrepreneurship Practice MCQ

View Set

BUS 110 Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13

View Set