quiz 6

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

If a reference type variable does not store a reference to an object, then it stores _____.

a null reference

Objects encapsulate state.

true

When there are no remaining references to an object in your Java program, the object will be destroyed.

true

You can create an object from a concrete class, but not from an abstract class.

true

Which of the following is/are true about arrays? Choose all that apply. - the elements of an array all located contiguously in memory - the elements of an array all have the same data type - none of these - an array is a set of variables - the elements of an array are accessed by an integer index

- the elements of an array all located contiguously in memory - the elements of an array all have the same data type - an array is a set of variables - the elements of an array are accessed by an integer index

How many private methods are there? Refer to the following UML Class Diagram when answering this question. Pet - name : int - age : String - hasFleas : Boolean + licenseNumber : String + weight : float + Pet() + Pet(name : String, age : int) + getName() : String - setName(name : String) : void + getAge() : int + setAge(age : int) : void + speak() : void - scratch(itches : int) : void + toString() : String

2

Evaluate the following code to determine the output. int x = 89, y = 11; y = x; y = 21; System.out.println(y);

21

Evaluate the following code to determine the output. int x = 28, y = 57; y = x; y = 92; System.out.println(x);

28

Evaluate the following code to determine the output. class Foo { public int i = 80; public Foo(int i) { this.i = i; } } ... Foo x = new Foo(35), y = new Foo(19); y.i = x.i; y.i = 42; System.out.println(x.i);

35

Evaluate the following code to determine the output. class Foo { public int i = 74; public Foo(int i) { this.i = i; } } ... Foo x = new Foo(74), y = new Foo(31); y = x; y.i = 36; System.out.println(x.i);

36

Which object oriented element is used to define "has a" relationships?

Composition

A value type variable can store a null reference in Java.

false

Java Boolean literal values are expressed in all uppercase.

false

Members that are public in the derived class are visible in the super class.

false

Given the following partial code, fill in the blank to complete the code necessary to insert node x in between the first two nodes. (don't forget the semicolon) ... class Node { public Object data = null; public Node next = null; } ... Node head = new Node(); // first Node head.next = new Node(); // second Node head.next.next = new Node(); // third node Node x = new Node(); // node to insert x.next = head.next; //_____________________ //

head.next = x;

Given the following partial code, fill in the blank to complete the code necessary to remove last node. (don't forget the semicolon) ... class Node { public Object data = null; public Node next = null; } ... Node head = new Node(); // first Node head.next = new Node(); // second Node head.next.next = new Node(); // third node head.next.next.next = new Node(); // fourth node _____________________ //

head.next.next.next = null;

Creating an object of a class is called _____.

instantiation

How many public methods (including constructors) does this class have? Refer to the following UML Class Diagram when answering this question. Pet - name : int + age : String + hasFleas : Boolean - licenseNumber : String + weight : float- color : String - Pet() + Pet(name : String, age : int) + getName() : String + setName(name : String) : void - getAge() : int - setAge(age : int) : void + speak() : void + scratch(itches : int) : void + toString() : String

6

Which object oriented element best allows us to designing and implementing families of related types that share outward similarities, but have specialized behaviors?

Polymorphism

To help us collect information from the user through the keyboard in Java, we use a(n) _____.

Scanner


Conjuntos de estudio relacionados

Conflict of Interest in Health Care

View Set

Med Surge Sensory : Practice Questions

View Set

Marketing Ch.15 Practice Questions

View Set

Chapter 9 - Teaching and Counseling

View Set

Environmental Science: Acid Rain and Air Pollution

View Set

Property & Casualty - PA - Insurance Regulation

View Set