Comp Sci Chapter 4 MC

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

To define a class that will represent a char, which of the following definitions is most appropriate?

public class Car

A class constructor usually defines

how an object is initialized

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

it must be a void method

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 behavior of an object is defined by the object's

methods

Which of the following 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 classes

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

"00"

If we have Swapper r=new Swapper (5, "no", 10) then r.swap(); returns which of the following?

"no"

In order to preserve encapsulation of an object, we would do all of the following except for which one?

Make the class final

Which of the following could be used to instantiate a new Student s1?

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

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

The instance data z is visible outside of Swapper

Which of the following sets of code will perform the coin flip and see if the user's guess was right or wrong?

c.flip(); if(c.toString().equals(guess)) System.out.println("User is correct");

Another method that might be desired is one that updates the Student's number of credit hours. Which of the following methods would accomplish this?

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

Assume that another method has been defined that will compute and return the student's class rank. Given that s1 is a student, which of the following would properly be used to get s1's class rank?

s1.getClassRank();

What does the following code compute?

the percentage of heads flipped out of 100 flips.


Ensembles d'études connexes

Chapter 3 - Database System and Big Data - Principles of Information Technology

View Set

Professional Behaviors / Professionalism NUR103-PrepU

View Set

Pathophysiology Ch. 8 Infection and Defects in Mechanisms of Defense

View Set

Fundamentals VSIM FINAL (ALL pre and post Q)

View Set

F**K STUDYING (swearing and taboo language)

View Set

Language Arts - Parts of Speech and Types of Phrases assignment

View Set

ACC 312 - Managerial Accounting Chapters 1-3

View Set

history chapter 19 online quizzes, Ch. 18 self check quizzes, history ch. 16 online quizzes

View Set

Hydrology and fluvial geomorphology

View Set

Signals of a heart attack, the 5 P's

View Set