PRO192 - Interface and Abtract

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

Which statement is not true in java language? Select one: a. A private member of a class cannot be accessed by the methods of the same class. b. A private member of a class cannot be accessed from its derived class. c. A public member of a class can be accessed in all the packages. d. A protected member of a class can be accessed from its derived class. e. None of the above.

a. A private member of a class cannot be accessed by the methods of the same class.

An abstract class can only contain abstract methods. Select one: a. False b. True

a. False

A protected member can be accessed in, Select one: a. a non-subclass of the same package b. the same class c. a non-subclass of different package d. a subclass of the same package e. a subclass of different packag

a. a non-subclass of the same package

An abstract class can contain ____. Select one: a. abstract and non-abstract methods b. only non-abstract methods c. only abstract methods d. nothing

a. abstract and non-abstract methods

What is the correct syntax for defining a new class Parakeet based on the superclass Bird? Select one: a. class Parakeet extends Bird{ } b. class Parakeet isa Bird{ } c. class Bird defines Parakeet{ } d. class Bird hasa Parakeet{ }

a. class Parakeet extends Bird{ }

What type of inheritance does Java support? Select one: a. single inheritance b. multiple inheritance c. double inheritance d. Java does not support inheritance

a. single inheritance

Suppose that the class Mystery is derived from the class Secret. Consider the following statements: Secret mySecret = new Secret(); Secret secRef; Mystery myMystery = new Mystery(); Mystery mysRef; secRef = myMystery; Which of the following statements is legal in Java? (i) mysRef = (Mystery) mySecret; (ii) mysRef = (Mystery) secRef; Select one: a. Only (i) b. Both (i) and (ii) c. None of these d. Only (ii)

b. Both (i) and (ii)

Redefining a method of a superclass is also known as overloading a method. Select one: a. True b. False

b. False

If a class implements an interface, it must ____. Select one: a. override all variables from the interface b. provide definitions for each of the methods of the interface c. override all constants from the interface d. rename all the methods in the interface

b. provide definitions for each of the methods of the interface

Object oriented inheritance models the Select one: a. "contains" of relationship. b. inheritance does not describe any kind of relationship between classes c. "is a kind of" relationship d. "want to be" relationship e. "has a" relationship

c. "is a kind of" relationship

What is the output of this program? class A { public void print() { System.out.println("A"); } } class B extends A { public void print() { super.print(); System.out.println("B"); } } class C extends B { public void print() { System.out.println("C"); } } class Test { public static void main(String[] args) throws Exception { A a = new C(); a.print(); } } Select one: a. ABC b. A c. C d. Compile error

c. C

Which operator is used to determine if an object is of a particular class type? Select one: a. The dot (.) operator b. The operator new c. The instanceof operator d. The + operator

c. The instanceof operator

Which of the following is not true? Select one: a. An interface can extend another interface. b. None of the above. c. A class which is implementing an interface must implement all the methods of the interface. d. An interface can implement another interface. e. An interface is a solution for multiple inheritance in java.

d. An interface can implement another interface.

How many interfaces can a class implement? Select one: a. 2 b. 1 c. 0 d. There is no limit to the number of interfaces that can be implemented by a single class.

d. There is no limit to the number of interfaces that can be implemented by a single class.

An abstract class ____. Select one: a. is the base class of all other classes b. is a superclass with many subclasses c. does not have any subclasses d. cannot be instantiated

d. cannot be instantiated

Which one of the following is not true? Select one: a. A class must be qualified as 'abstract' class, if it contains one abstract method. b. A class containing abstract methods is called an abstract class. c. Abstract methods should be implemented in the derived class. d. None of the above. e. An abstract class cannot have non-abstract methods.

e. An abstract class cannot have non-abstract methods.

When an overridden method is called from within a subclass, it will always refer to the version of that method defined by the Select one: a. Interpreter will choose randomly b. Compiler will choose randomly c. Super class d. None of the abvove. e. Subclass

e. Subclass


Conjuntos de estudio relacionados

AP Gov't - Unit 5 - Civil Liberties; Civil Rights Quiz; Judicial Branch

View Set

Human Anatomy Chapter 4 Practice Questions

View Set

Inquizitive Questions + Practice Quiz Soc 1

View Set

Chapter 8: Disorders of Fluid and Electrolyte and Acid Base Balance

View Set