quiz

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

An object can automatically be upcast to its super type, or the type of any interface that it implements.

True

In Java, interfaces facilitate a form of multiple inheritance because when a class implements an interface its public interface then includes methods defined by both its superclass and the interface.

True

In java, interfaces facilitate a form of multiple inheritance because when a class implements an interface its public interface then includes methods defined by both its superclass and the interface.

True

The substitution principle defines that objects of a superclass shall be replaceable with objects of its subclasses without breaking the application.

True

You should use an interfaces over an abstract class when you want to force similar behavior across disparate classes.

True

Aggregation is a

"Has a" relationship

Assume you must represent a college course that contains: Course Name A course has course name, room number, and a textbook Textbook A textbook has a title and an edition Select the correct relationship between the Textbook and Course objects?

Aggregation

Select the option that best compares Aggregation and Composition.

Aggregation is represented as a "conceptual" relationship, whereas composition is represented as a "death" relationship

Select the not true statement. Polymorphism

All of these statements are true

Suppose you had two data definition classes, Disease and ViralDisease. ViralDisease extends Disease. Assume in your implementation class, you had created an array of Disease objects. When looping through the array of Disease objects, how would you check to see if the current object was a ViralDisease?

By using the instanceof operator

Based on the following statement, select the interface class. public class ClassA extends ClassB implements ClassC

ClassC

Aggregation and Composition are not examples of an association.

False

Given the data definition classes below, add line(s) to the implementation class HouseImplementation to demonstrate polymorphism. 1 public class House { 2 public void setAddress(){} 3 public double calculateCost(){} 4 } 1 public class NewConstruction extends House { 2 public double calculateCost(){} 3 public void setMaterialList(String[] list){} 4 } 1 public class HouseImplementation { 2 public static void main (String[] args){ 3 // Lines will go here 4 } 5 }

House aHouse = new NewConstruction(); aHouse.calculateCost();

Given the following class hierarchy and implementation class below, what would be the output on line 18. 1 public abstract class Product{ 2 public abstract String WhatAmI(); 3 } 4 public class Book extends Product { 5 public String WhatAmI() { 6 return " I am a Book"; 7 } 8 } 9 public class Magazine extends Product { 10 public String WhatAmI() { 11 return " I am a Magazine"; 12 } 13 } 14 public class ProductImplementation { 15 public static void main(String[] args) { 16 Product p1 = new Book(); 17 Product p2 = new Magazine(); 18 JoptionPane.showMessageDialog(null, p1.WhatAmI()); 19 } 20 }

I am a Book

To determine whether two objects are equal you would

Implement the equals method

What is the output of the following code? interface A { void methodOne(); } interface B extends A { void methodTwo(int i); } abstract class C implements B { public void methodOne() { System.out.println("Inside class C"); methodTwo(2); } } class D extends C { public void methodTwo(int i) { System.out.println("Inside class D"); } } class Main { public static void main(String[] args) { A test = new D(); test.methodOne(); } }

Inside class C Inside class D

With your new found free time, you decide to write a Book. Based on your research you determine that cookbooks are one of the most popular nonfiction genres. Based on your research, you find that the best selling cookbooks follow the below pattern: Each Cookbook should have between 5 to 12 Chapters Each Chapter must be defined as either a 'FrenchCooking','ChineseCooking','TurkiskCooking','IndianCooking', or 'ItalianCooking' Each Chapter should have between 1 to 15 recipes Given the above description, select the best option that descripts the Cookbook pattern.

NOT A Cookbook has a composition relationship with Chapter and a multiplicity of 1 to 5...12

instance variable of an interface can be specified as ________

NOT public final static final

Which of the following is the correct way of implementing an interface A by class B?

class B implements A{ }

Which of the following is a correct interface definition?

public interface A { void print(); }


संबंधित स्टडी सेट्स

Nervous System: The Brain and Spinal Cord

View Set

Vocabulario-La Navidad en Camelot lista 1 (1/2)

View Set

Geometry B Unit 2 Post-test Connecting Algebra and Geometry through Coordinates

View Set

chapter one: humans and the microbial world

View Set

Econ 120 (Macro) - Chapter 13 Quiz Questions

View Set

Chapter 5: Identifying and Preserving Evidence

View Set