Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
Question
Book Icon
Chapter 13.8, Problem 13.8.3CP

a)

Program Plan Intro

Abstract class:

An abstract class is a class which may or may not include abstract methods and cannot be instantiated but rather can be sub classed.

Legal abstract class:

The conditions for a class to be considered as legal abstract class are mentioned below:

  • If a class includes abstract methods, then the class must be declared as abstract.
  • The abstract method that is declared within the abstract class must be declared without braces and followed by a semicolon.

Interface:

Interface is a reference type in Java, which contains a collection of abstract methods.

An interface needs to the follow certain conditions such as:

  • One cannot instantiate an interface.
  • Interfaces do not contain any constructors.
  • All methods present in the interface are abstracts.
  • An interface does not contain any instance field.
  • An interface cannot be extended by a class.

b)

Program Plan Intro

Abstract class:

An abstract class is a class which may or may not include abstract methods and cannot be instantiated but rather can be sub classed.

Legal abstract class:

The conditions for a class to be considered as legal abstract class are mentioned below:

  • If a class includes abstract methods, then the class must be declared as abstract.
  • The abstract method that is declared within the abstract class must be declared without braces and followed by a semicolon.

Interface:

Interface is a reference type in Java, which contains a collection of abstract methods.

An interface needs to the follow certain conditions such as:

  • One cannot instantiate an interface.
  • Interfaces do not contain any constructors.
  • All methods present in the interface are abstracts.
  • An interface does not contain any instance field.
  • An interface cannot be extended by a class.

c)

Program Plan Intro

Abstract class:

An abstract class is a class which may or may not include abstract methods and cannot be instantiated but rather can be sub classed.

Legal abstract class:

The conditions for a class to be considered as legal abstract class are mentioned below:

  • If a class includes abstract methods, then the class must be declared as abstract.
  • The abstract method that is declared within the abstract class must be declared without braces and followed by a semicolon.

Interface:

Interface is a reference type in Java, which contains a collection of abstract methods.

An interface needs to the follow certain conditions such as:

  • One cannot instantiate an interface.
  • Interfaces do not contain any constructors.
  • All methods present in the interface are abstracts.
  • An interface does not contain any instance field.
  • An interface cannot be extended by a class.

d)

Program Plan Intro

Abstract class:

An abstract class is a class which may or may not include abstract methods and cannot be instantiated but rather can be sub classed.

Legal abstract class:

The conditions for a class to be considered as legal abstract class are mentioned below:

  • If a class includes abstract methods, then the class must be declared as abstract.
  • The abstract method that is declared within the abstract class must be declared without braces and followed by a semicolon.

Interface:

Interface is a reference type in Java, which contains a collection of abstract methods.

An interface needs to the follow certain conditions such as:

  • One cannot instantiate an interface.
  • Interfaces do not contain any constructors.
  • All methods present in the interface are abstracts.
  • An interface does not contain any instance field.
  •  An interface cannot be extended by a class.

e)

Program Plan Intro

Abstract class:

An abstract class is a class which may or may not include abstract methods and cannot be instantiated but rather can be sub classed.

Legal abstract class:

The conditions for a class to be considered as legal abstract class are mentioned below:

  • If a class includes abstract methods, then the class must be declared as abstract.
  • The abstract method that is declared within the abstract class must be declared without braces and followed by a semicolon.

Interface:

Interface is a reference type in Java, which contains a collection of abstract methods.

An interface needs to the follow certain conditions such as:

  • One cannot instantiate an interface.
  • Interfaces do not contain any constructors.
  • All methods present in the interface are abstracts.
  • An interface does not contain any instance field.
  •  An interface cannot be extended by a class.

Blurred answer
Students have asked these similar questions
A. Writing an Interface In this problem you will first write an interface and then modify classes to implement the interface. Write an interface, GeometricSolid, which has one method, volume. The volume method takes no arguments and returns a double. You are provided with three classes: Cylinder, Sphere, and RightCircularCone Modify the classes so that they implement the GeometricSolid interface. Supply the appropriate method for each class. You can use Google search to find the formula for the volume. Make sure that you use Math.PI in your calculations. Notice in InterfaceRunner that the objects are added to an ArrayList of GeometricSolids. since I couldn't fit all images with two screen shots I left the link here link: https://codecheck.it/files/18040616319p6jy6gzkdzuq08nmlp81251t
You cannot instantiate an interface but you can do so to an abstract class. True False
What is/are the differences between an abstract class and an interface? A class can implement multiple interfaces, but only extend one abstract class An interface can contain attributes None of the given All of the given Only interfaces can have default function implementations

Chapter 13 Solutions

Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)

Ch. 13.4 - How do you create a Calendar object for the...Ch. 13.4 - For a Calendar object c, how do you get its year,...Ch. 13.5 - Prob. 13.5.1CPCh. 13.5 - Prob. 13.5.2CPCh. 13.5 - Prob. 13.5.3CPCh. 13.5 - Prob. 13.5.4CPCh. 13.6 - Prob. 13.6.1CPCh. 13.6 - Prob. 13.6.2CPCh. 13.6 - Can the following code be compiled? Why? Integer...Ch. 13.6 - Prob. 13.6.4CPCh. 13.6 - What is wrong in the following code? public class...Ch. 13.6 - Prob. 13.6.6CPCh. 13.6 - Listing 13.5 has an error. If you add list.add...Ch. 13.7 - Can a class invoke the super.clone() when...Ch. 13.7 - Prob. 13.7.2CPCh. 13.7 - Show the output of the following code:...Ch. 13.7 - Prob. 13.7.4CPCh. 13.7 - What is wrong in the following code? public class...Ch. 13.7 - Show the output of the following code: public...Ch. 13.8 - Prob. 13.8.1CPCh. 13.8 - Prob. 13.8.2CPCh. 13.8 - Prob. 13.8.3CPCh. 13.9 - Show the output of the following code: Rational r1...Ch. 13.9 - Prob. 13.9.2CPCh. 13.9 - Prob. 13.9.3CPCh. 13.9 - Simplify the code in lines 8285 in Listing 13.13...Ch. 13.9 - Prob. 13.9.5CPCh. 13.9 - The preceding question shows a bug in the toString...Ch. 13.10 - Describe class-design guidelines.Ch. 13 - (Triangle class) Design a new Triangle class that...Ch. 13 - (Shuffle ArrayList) Write the following method...Ch. 13 - (Sort ArrayList) Write the following method that...Ch. 13 - (Display calendars) Rewrite the PrintCalendar...Ch. 13 - (Enable GeometricObject comparable) Modify the...Ch. 13 - Prob. 13.6PECh. 13 - (The Colorable interface) Design an interface...Ch. 13 - (Revise the MyStack class) Rewrite the MyStack...Ch. 13 - Prob. 13.9PECh. 13 - Prob. 13.10PECh. 13 - (The Octagon class) Write a class named Octagon...Ch. 13 - Prob. 13.12PECh. 13 - Prob. 13.13PECh. 13 - (Demonstrate the benefits of encapsulation)...Ch. 13 - Prob. 13.15PECh. 13 - (Math: The Complex class) A complex number is a...Ch. 13 - (Use the Rational class) Write a program that...Ch. 13 - (Convert decimals to fractious) Write a program...Ch. 13 - (Algebra: solve quadratic equations) Rewrite...Ch. 13 - (Algebra: vertex form equations) The equation of a...
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
  • Text book image
    Microsoft Visual C#
    Computer Science
    ISBN:9781337102100
    Author:Joyce, Farrell.
    Publisher:Cengage Learning,
    Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT