Chapter 10 - Part 4

Ace your homework & exams now with Quizwiz!

T/F: An abstract class is not instantiated itself but serves as a superclass for other classes.

True

If a method in a subclass has the same signature as a method in the superclass, the subclass method ________ the superclass method.

overrides

All methods specified by an interface are ________.

public

Given the following code, which statement is true? public class ClassB implements ClassA{ }

ClassB must override each method in ClassA.

T/F: All methods in an abstract class must also be declared abstract.

False

T/F: If two methods in the same class have the same name but different signatures, the second overrides the first.

False

If a subclass constructor does not explicitly call a superclass constructor ________.

Java will automatically call the superclass's default or no-arg constructor just before the code in the subclass's constructor executes

Line 1 public class ClassA Line 2 { Line 3 public ClassA() {} Line 4 public void method1(int a){} Line 5 } Line 6 public class ClassB extends ClassA Line 7 { Line 8 public ClassB(){} Line 9 public void method1(){} Line 10 } Line 11 public class ClassC extends ClassB Line 12 { Line 13 public ClassC(){} Line 14 public void method1(){} Line 15 } Which method will be executed when the following statements are executed? ClassC item1 = new ClassA(); item1.method1();

This is an error and will cause the program to crash.

Line 1 public class ClassA Line 2 { Line 3 public ClassA() {} Line 4 public void method1(int a){} Line 5 } Line 6 public class ClassB extends ClassA Line 7 { Line 8 public ClassB(){} Line 9 public void method1(){} Line 10 } Line 11 public class ClassC extends ClassB Line 12 { Line 13 public ClassC(){} Line 14 public void method1(){} Line 15 } Which method1 will be executed when the following statements are executed? ClassA item1 = new ClassB(); item1.method1();

method1 on Line 9

If two methods have the same name but different signatures they are ________.

overloaded

T/F: Because every class directly or indirectly inherits from the Object class, every class inherits the Object class's members.

True

T/F: Because the subclass is more specialized than the superclass, it is sometimes necessary for the subclass to replace inadequate superclass methods with more suitable ones.

True

T/F: Every class has a toString method and an equals method inherited from the Object class.

True

T/F: If a method in a subclass has the same signature as a method in the superclass, the subclass method overrides the superclass method.

True

If a class contains an abstract method ________.

the method will only have a header, but not a body, and will end with a semicolon, the method cannot be overridden in subclasses, and you must create an instance of the class


Related study sets

Performance Management and Appraisal

View Set

Operator 1 chapter 6 Trickling filters

View Set

Total Health Chapter 7 - Stress and Anxiety

View Set

Chapter 12: Behavioral Emergencies

View Set

Salesforce Marketing Cloud Administration Exam

View Set

Introduction to Career Skills in Data Analytics

View Set

Chapter 14 - Miscellaneous Commercial Lines Coverage

View Set

DHS 1110 01---Introduction to Health Professions Part 2

View Set