ITSS 3312

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

If object1 and object2 are objects of the same class, to make object2 a copy of object1 A.write a method for the class that will make a field by field copy of object1data members into object2data members B.use the copy method that is a part of the Java API C.use the default constructor to create object2with object1data members D. use an assignment statement to make object2 a copy of object1

A

When a class contains an abstract method, you cannot create an instance of the class A. True B. False

A. True

A ragged array has a.Each rows has different length b.Each column has different length c.The current row has one more element than the next row to follow d.It is a triangle array

A

A subclass inherits all public instance variables and methods of the superclass, but does not inherit the A.Private variables and methods B.Protected variables and methods C.Just the Private variables D.The default variables

A

A(n) __________ method is a method that appears in a superclass but expects to be overridden in a subclass.} a.abstract b.protected c.static d.overloaded

A

Any ___________ argument passed to the character classes toLowerCase method or toUpperCase method is returned as it it. A. nonletter B.char C. String D. Static

A

Given the following method header, what will be returned from the method? public Rectangle getRectangle() a.the address of an object of the Rectangle class b.the values stored in the data members of the Rectangle object c.a null value d.an object that is contained in the class Rectangle

A

Enclose the target object type in parentheses and place it before the object to be cast, as follows: Student b = (Student)o; A.implicit casting B.overriding C.dynamically binding D.explicit casting

D

The String classes _____________ method accepts a value of any primitive data type as its arguments and returns a string representation of the value A. Trim B. getChar C. toString D. valueOf

D

The state of an object describes the properties of the object A. True B. False

A. True

The statement Object o = new Student()work A. True B. False

A. True

If you have defined a class, SavingsAccount, with a public method, getNumberOfAccounts, and created a SavingsAccountobject referenced by the variable account20, which of the following will call the getNumberOfAccounts method? a.account20.getNumberOfAccounts(); b.SavingsAccount.getNumberOfAccounts(); c.getNumberOfAccounts(); d.SavingsAccount.account20.getNumberOfAccounts();

A

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 subclass of C3,...,and Cn-1 is a subclass of Cn .JVM searches the implementation for the method pin C1,C2,...,Cn-1andCn A. True B. False

A

The compiler ______________ a method according to parameter type, number of parameters , and order of the parameters at compilation time. A.matches B.binds C.compiles D.dynamically binds

A

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; } } a.This shuffles all elements in an array b.This initializes all elements in a row c.This initializes all elements in a column d.This initializes all the elements in an array

A

What is the length of a two-dimensional array? A.It is the number of rows B.It is the number of columns C.It is the sum of number of rows and columns D.It is the number of rows times columns

A

When the this variable is used to call a constructor a.it must be the first statement in the constructor making the call b.it can be anywhere in the constructor making the call c.it must be the last statement in the constructor making the call d.None of these. You cannot use the this variable in a constructor call.

A

__________ is the term for the relationship created by object aggregation. A "Has a" B Inner class C "Is a" D. One-to-many

A

A class's static methods do not operate on the fields that belong to any instance of the class. A. True B. False

A. True

A type defined by a subclass is called a subtype and a type defined by its superclass is called a supertype A. True B. False

A. True

Because every class directly or indirectly inherits from the Object class, ever class inherits the object classes members A. True B. False

A. True

Constructors have no return type A. True B. False

A. True

Explicit casting must be used when casting an object from a superclass to a subclass. Example = Apple x = (Apple)fruit; A. True B. False

A. True

If a method's parameter type is a superclass you may pass an object to this method of any of the parameter' s subclass A. True B. False

A. True

Inheritance is used to avoid duplicating code in subclasses A. True B. False

A. True

Martini extends Beverage. Is this relationship valid? A. True B. False

A. True

Polymorphism means that a variable of a super type can refer to a subtype object. A. True B. False

A. True

The key word this is the name of a reference variable that an object can use to refer to itself. A. True B. False

A. True

A ____________ is an object created from a class. A. methods B. Instance C. Copy constructor D.Constructor

B

Data stored in an Object are known as ___________and the operations that the object can perform are known as ___________ in Java. a.Data, methods b.Fields, methods c.Fields, functions d.Variables, methods

B

The only limitation that static methods have is a.they must be declared outside of the class b.they cannot refer to nonstatic members of the class c.they can only be called from static members of the class d.they can refer only to nonstatic members of the class

B

Which of the following is a correct method header for receiving a two-dimensional array as an argument? A.public static void passMyArray(int[]myArray1, int[]myArray2) B.public static void passMyArray(int[][] myArray) C.public static void passMyArray[][](int myArray) D.public static void passMyArray(array myArray)

B

If you have defined a class, SavingsAccount, with a public static method, getNumberOfAccounts, and created a SavingsAccountobject referenced by the variable account20, which of the following will call the getNumberOfAccounts method? a.account20.getNumberOfAccounts(); b.SavingsAccount.getNumberOfAccounts(); c.getNumberOfAccounts(); d.SavingsAccount.account20.getNumberOfAccounts();

B.

Metal extends Titanium. Is this relationship valid? A. True B. False

B. False

Person extends Employee. Is this relationship valid? A. True B. False

B. False

We can assign the object reference o to a variable of the Student type using the following statement: A. True B. False

B. False

instance variables can be overridden A. True B. False

B. False

A ____________is code that describes a particular type of object. a.methods b.to string methods c.class d.constructor

C

Assume the class BankAccounthas been created and the following statement correctly creates an instance of the class. BankAccountaccount = new BankAccount(5000.00); What is true about the following statement?System.out.println(account); A runtime error will occur. b.The method will display unreadable binary data on the screen. c.The accountobject's toStringmethod will be implicity called. d.A compiler error will occur.

C

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. a.static b.dynamic c.polymorphic d.public

C

The JVM ______________ a method according to parameter type , number of parameters , and order of the parameters at compilation time. a.memory shuffling b.system restore c.garbage collection d.memory sweeping

C

The JVM periodically performs the __________ process to remove unreferenced objects from memory. A. Memory shuffling B. System restore C. Garbage collection D. Memory sweeping

C

The Java Virtual Machine determines at runtime which method to call, depending on the type of object that the variable references. This is A.overloading B.overriding C.dynamically binding D.compiling

C

The _________ are used to perform operations at the time an object is created. A.Methods B.toString C.constructors D.Copyconstructors

C

The_________modifier will prevent the overriding of a superclass method in a subclass. A.private B.public C.final D.protected

C

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); a.This is the sum of all elements in an array b.This is the sum of all elements in a row c.This is the sum of all elements in a column d.This is printing all the elements in an array

C

What is the value of scores[2][3]in the following array? int[][] scores = { {88, 80, 79, 92}. {75, 84, 93, 80}, {98, 95, 92, 94}, {91, 84, 88, 96} }; a.95 b.84 c.94 d.93

C

What will be displayed after the following code is executed? 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)); } a.ABC b.ABC456 c.456 d.abc456

C

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; } Package p2; Public class B{A a= new A(); }

Can not access a.x

Package p1; Public class A { public int x; private int y; protected int z; int u; } Package p2; Public class B extends A { }

Can not access z


Conjuntos de estudio relacionados

Microeconomics Quiz 2: Choice in a World of Scarcity

View Set

Intro to Business Final Exam EHS

View Set

OST-184 - Records Management - Module 4

View Set

Global Issues: Actors on the World Stage

View Set

Manufacturing Processes- Week 1 ch. 5

View Set

Jordan - Old American Government Terms

View Set

45 - week 4 - Algebra 1 pg. 33- 45

View Set

Неврологія задачі

View Set