Exam 3

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

Which of the following are Java keywords?

instanceof

Which of the statements regarding the super keyword is incorrect? A) You can use super to invoke a super class constructor. B) You cannot invoke a method in superclass's parent class. C) You can use super.super.p to invoke a method in superclass's parent class. D) You can use super to invoke a super class method.

C

What is the output of the following code: public class Test { public static void main(String[ ] args) { Object o1 = new Object(); Object o2 = new Object(); System.out.print((o1 == o2) + " " + (o1.equals(o2))); } }

false false

What is the output of the following code: public class Test { public static void main(String[ ] args) { String s1 = new String("Java"); String s2 = new String("Java"); System.out.print((s1 == s2) + " " + (s1.equals(s2))); } }

false true

Inheritance means ________.

that a class can extend another class

Polymorphism means ________.

that a variable of supertype can refer to a subtype object

Encapsulation means ________.

that data fields should be declared private

Given the declaration Circle[ ] x = new Circle[10], which of the following statement is most accurate?

x contains a reference to an array and each element in the array can hold a reference to a Circle

Which of the following statement is false? (Choose all that apply.) A) At least one constructor must always be defined explicitly. B) Constructors must have the same name as the class itself. C) A default no-arg constructor is provided automatically if no constructors are explicitly declared in the class. D) Constructors are invoked using the new operator when an object is created. E) Constructors do not have a return type, not even void.

A

An object is an instance of a ________.

A class

________ is a construct that defines objects of the same type

A class

________ is invoked to create an object.

A constructor

Which of the following statement is true?

A subclass is usually extended to contain more functions and more detailed information than its superclass.

________ represents an entity in the real world that can be distinctly identified.

An object

Which of the following statement is true? A) A method can be overridden in the same class. B) If a method overrides another method, these two methods must have the same signature. C) A method cannnot be overloaded in the same class. D) If a method overloads another method, these two methods must have the same signature

B

Given the declaration Circle x = new Circle(), which of the following statement is most accurate? A) x contains an object of the Circle type. B) x contains an int value. C) x contains a reference to a Circle object. D) You can assign an int value to x.

C

Object-oriented programming allows you to derive new classes from existing classes. This is called ________.

Inheritance

Which is the advantage of encapsulation?

It changes the implementation without changing a class's contract and causes no consequential changes to other code.

When invoking a method with an object argument, ________ is passed.

The reference of the object

A Java exception is an instance of ________.

Throwable

The keyword ________ is required to declare a class.

class


Ensembles d'études connexes

Ch 27 Anger, Aggression, and Violence Varcarolis

View Set

AP U.S. History Chapter 1 Review

View Set

Lord of the Flies Chapter 5 and 6 Vocab

View Set

Chapter 4: Health of the individual, family, and community.

View Set

Chapter 4 - Downers, uppers downers, all arounders

View Set

Conceptual Physics 10: Projectile and Satellite Motion

View Set

Karch's Prep U (Pharm) Ch 46: Lipid Lowering Agents

View Set

Types of Individual Life Insurance

View Set