ITSS 3312 Final

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

_ is the term for the relationship created by object aggregation

"Has a"

What is the values of score[2][3] in the following array? int[][] scores = { {88,80,79,92}, {75,84,93,80}, {98,95,92,94}, {91,84,88,96} };

94

Which of the following is not correct? Package p1; Public class A { public int x; private int y; protected int z; int u; } Package p2; Public class B extends A {}

Cannot access z; van access protected variables

A _ is code that describes a particular type of object

Class

The _ are used to perform operations at the time an object is created

Constructors

The JVM periodically performs the _ process to remove unreferenced objects from memory

Garbage collectio

What is the length of a two-dimensional array

It is the number of rows

When the this variable is used to call a constructor

It must be the first statement in the constructor making the call

The compiler _ a method according to parameter type, number of parameters, and order of the parameters at compilation time

Matches

In Java, a reference variable is _ because it can reference objects of types different from its own, as long as those types are related to its type through inheritance

Polymorphic

The only limitation that static methods have is

They cannot refer to nonstatic members of the class

Martini extends Beverage. Is this relationship valid?

True

If object1 and object2 are objects of the same class, to make object2 a copy of object1

Write a method for the class that will make a field by field copy of object1 data members into object2 data members

If you have defined a class, SAvingsAccount, with a public method, getNumberOfAccounts, and created a SavingsAccount object referenced by the variable account20, which of the following will call the getNumberOfAccounts method?

account20.getNumberOfAccounts();

Any _ argument passed to the Character class's toLowerCase method or toUpperCase method is returned as it is

char

Which of the following is a correct method header for receiving a two-dimensional array as an argument

public static void passMyArray(int[][] myArray)

The String class's _ method accepts a value of any primitive data type as its argument and returns a string representation of the value

valueOf

A subclass inherits all public instance variables and methods of the superclass, but does not inherit the

Private variables and methods

If you have a defined a class, SavingsAccount, with a public static method, getNumberOfAccounts, and created a SavingsAccount object referenced by the variable account20, which of the following will call the getNumberOfAccounts method?

SavingsAccount.getNumberOfAccounts();

Assume the class BankAccount has been created and the following statement correctly creates an instance of the class. BankAccount account = new BankAccount(5000.00); What is true about the following statement? System.out.println(account);

The account object's toString method will be implicitly called

Given the following method header, what will be returned from the method? public Rectangle getRectangle()

The address of an object of the Rectangle class

What does the following code do? for (int column = 0; column < matrix[0].length; column++) { int total = 0; for (int row = 0; row < matrix.length; row++) total += matrix[row][column]; System.out.println("Sum is " + total); }

This is the sum of all elements in a column

What does the following code do? for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix[i].length; j++) { int i1 = (int)(Math.random() * matrix.length); int j1 = (int)(Math.random() * matrix[i].length); // Swap matrix[i][j] with matrix[i1][j1] int temp = matrix[i][j] matrix[i][j] = matrix [i1][j1]; matrix [i1][j1] = temp; }}

This shuffles all elements in an array

A class's static methods do no operate on the fields that belong to any instance of the class

True

A type defined by a subclass is called a subtype, and a type defined by its superclass is called a supertype

True

Because every class directly or indirectly inherits from the Object class, every class inherits the Object class's members

True

Constructors have no return type

True

If a method's parameter type is a superclass you may pass an object to this method of any of the parameter's subclasses

True

Inheritance is used to avoid duplicating code in subclasses

True

Polymorphism means that a variable of a supertype can refer to a subtype object

True

Suppose an object o is an instance of classes C1, C2, ..., Cn-1, and Cn, where C1 is a subclass of C2, C2 is a sublclass of C3, ..., and Cn-1 is a subclass of Cn. JVM searches the implementation for the method p in C1, C2, ..., Cn-1 and Cn

True

The key word this is the name of a reference variable that an object can use to refer to itself

True

The state of an object describes the properties of the object

True

When a class contains an abstract method, you cannot create an instance of the class

True

The statement Object o = new Student() work

True; Every object class is superclass of any other class

Explicit casting must be used when casting an object from a superclass to a subclass

True; Example Apple x =(Apple) fruit;

What will be displayed after the following code is? String str = "abc456"; for (int i = 0; i<str.length(); i++) { char chr = str.CharAt(i); if (!Character.isLetter(chr)) System.out.print(Character.toUpperCase(chr));}

456

A(n) _ method is a method that appears in a superclass but expects to be overridden in a subclass

Abstract

Which of the following is not correct? Package p1; {Public class A { public int x; private int y; protected int z; int u; } Public class B { A a = new A(); }}

Can access a.y

Which of the following is not correct? Package p1; {Public class A { public int x; private int y; protected int z; int u; } class B extends A { }}

Can access y

Which of the following is not correct? Package p1; Public class A { public int x; private int y; protected int z; int u; } Package p2; Public class B { A a = new A(); }

Cannot access a.x; can access a.x

The Java Virtual Machine determines at runtime which method to call, depending on the type of object that the variable references. This is

Dynamically binding

The JVM _ a method according to parameter type, number of parameters, and order of the parameters at compilation time

Dynamically binds

A ragged array has

Each rows has different length

Enclose the target object type in parentheses and place it before the object to be cast, as follows: Student b = (Student)o;

Explicit casting

If a string has more than one character used as a delimiter, you must write a loop to determine the tokens, one for each delimiter chracter

False

Instance variables can be overridden

False

Person extends Employee. Is this relationship valid?

False; Employee extends person

We can assign the object reference to a variable of the Student type using the following statement: student b = o;

False; Every object class is superclass of any other class. But reverse is not true

Metal extends Titanium. Is this relationship valid?

False; Titanium extends Metal

Data stored in an object are known as _ and the operations that the object can perform are known as _ in Java

Fields, methods

The _ modifier will prevent the overriding of a superclass method in a subclass

Final

A _ is an object created from a class

Instance


Conjuntos de estudio relacionados

Unit 4 - Ancient China - Chapters 19, 20, 22, 23, 24

View Set

Alternating Prone Extensions (Superman Exercise)

View Set

Chapter 13 Global Sourcing and Procrument

View Set

CL CV 201 - Quotes: The Iliad - Midterm

View Set

AGEC 3413 Chapter 10 Multiple Choice

View Set

Part 2: All Questions on eye/ear/pain/PVD i could find, hesi nclex-rn evolve book fundamentals

View Set