Starting Out with Programming Logic and Design (4th Edition)
4th Edition
ISBN: 9780133985078
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 14, Problem 16MC
The ___________ characteristic of object-oriented
- a. polymorphism
- b. inheritance
- c. generalization
- d. specialization
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
PLEASE ANSWER IN PYTHON
Scenario: Campus Pizza is really taking off and your co-founders love the programs you have built. They want you to build an object oriented program for their beverages. Campus pizza has two beverage options: Soda from the soda fountain, and home-made lemonade which is available as sweetened or unsweetened. Both beverages are $1.50 for a small, $1.75 for a medium and $2.00 for a large.
Program Guidelines:
Superclass: Create a superclass called "Beverage" that has two attributes: "size" and "price". "Beverage" should also have a method called "display" that prints out a statement of the size and price of the drink.
Subclasses:
Soda Subclass: Create a subclass "Soda" that inherits all the attributes and methods of Beverage.
Lemonade Subclass: Create a subclass "Lemonade" that inherits all the attributes of subclass, but add an attribute called "sugar" for whether the customer wants the lemonade sweetened or unsweetened. Additionally, edit the…
When a variable declared in a subclass has the same name as a variable declared in a superclass, it is called a _______________ variable.
Form a subclass StateQuarter from the class Coin. A state quarter has a state theme.
The toString method should yield a string such as
StateQuarter[value=0.25,name=Quarter][state=California]
/** A quarter with a state theme.*/public class StateQuarter extends Coin{ // Type your code here /** Constructs a state quarter. @param aState the state name */ public StateQuarter(String aState) { super(0.25, "Quarter"); // Type your code here } /** Gets the description of this object. @return a description of this coin */ public String toString() { // Type your code here }}
Chapter 14 Solutions
Starting Out with Programming Logic and Design (4th Edition)
Ch. 14.1 - What is an object?Ch. 14.1 - Prob. 14.2CPCh. 14.1 - Prob. 14.3CPCh. 14.1 - What are public methods? What are private methods?Ch. 14.2 - You hear someone make the following comment: A...Ch. 14.2 - In this chapter, we use the metaphor of a cookie...Ch. 14.2 - Prob. 14.7CPCh. 14.2 - Prob. 14.8CPCh. 14.2 - When a class variable is said to reference an...Ch. 14.2 - Prob. 14.10CP
Ch. 14.2 - Prob. 14.11CPCh. 14.2 - What is a constructor? When does a constructor...Ch. 14.2 - What is a default constructor?Ch. 14.3 - Prob. 14.14CPCh. 14.3 - Suppose a class has a field named description. The...Ch. 14.3 - Prob. 14.16CPCh. 14.4 - Prob. 14.17CPCh. 14.4 - What technique was described in this section for...Ch. 14.4 - What are classes responsibilities?Ch. 14.4 - Prob. 14.20CPCh. 14.5 - In this section, we discussed superclasses and...Ch. 14.5 - Prob. 14.22CPCh. 14.5 - What does a subclass inherit from its superclass?Ch. 14.5 - Look at the following pseudocode; which is the...Ch. 14.6 - Look at the following pseudocode class...Ch. 14 - Prob. 1MCCh. 14 - Prob. 2MCCh. 14 - A(n) ____ is a member of a class that holds data....Ch. 14 - The _________ specifies how a classs field or...Ch. 14 - A classs fields are commonly declared with the...Ch. 14 - Prob. 6MCCh. 14 - In many programming languages, the _____ key word...Ch. 14 - A(n) ____ method gets a value from a class's field...Ch. 14 - A(n) ____ method stores a value in a field or...Ch. 14 - A(n) ____ method is automatically called when an...Ch. 14 - A set of standard diagrams for graphically...Ch. 14 - When the value of an item is dependent on other...Ch. 14 - A classs responsibilities are _____. a. objects...Ch. 14 - In an inheritance relationship, the _____ is the...Ch. 14 - In an inheritance relationship, the _____ is the...Ch. 14 - The ___________ characteristic of object-oriented...Ch. 14 - The practice of procedural programming is centered...Ch. 14 - Object reusability has been a factor in the...Ch. 14 - It is a common practice in object-oriented...Ch. 14 - One way to find the classes needed for an...Ch. 14 - The superclass inherits fields and methods from...Ch. 14 - Polymorphism allows a class variable of the...Ch. 14 - Prob. 1SACh. 14 - Prob. 2SACh. 14 - What is the difference between a class and an...Ch. 14 - In many programming languages, what does the New...Ch. 14 - The following pseudocode statement calls an...Ch. 14 - Prob. 6SACh. 14 - What does a subclass inherit from its superclass?Ch. 14 - Look at the following pseudocode, which is the...Ch. 14 - Prob. 1AWCh. 14 - Look at this partial class definition, and then...Ch. 14 - Look at the following description of a problem...Ch. 14 - In pseudocode, write the first line of the...Ch. 14 - Look at the following pseudocode class...Ch. 14 - Pet Class Design a class named Pet, which should...Ch. 14 - Car Class Design a class named Car that has the...Ch. 14 - Personal Information Class Design a class that...Ch. 14 - Emp1oyee and ProductionWorker Classes Design an...Ch. 14 - Essay Class Design an Essay class that extends the...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Explain the difference between redundancy and diversity.
Software Engineering (10th Edition)
The following code fragment will not compile. Why? if !x x | y x = 2 + x; else x = x | 3;
Java: An Introduction to Problem Solving and Programming (8th Edition)
Bond Yield One measure of a bond's performance is its Yield To Maturity (YTM). YTM values for government bonds ...
Introduction To Programming Using Visual Basic (11th Edition)
What is an object?
Starting Out With Visual Basic (7th Edition)
If the memory cell whose address is 5 contains the value 8, what is the difference between writing the value 5 ...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
What is a source program? What is an object program?
Problem Solving with C++ (10th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- True or False:Unlike other members of a superclass, constructors of a superclass are not inherited by its subclasses. This means that you must define a constructor for a class or use the default constructor added by the compiler.arrow_forward1. Create an interface OnlineQuiz with the following details: Member variables: totalMarks=10 Member Methods: · nQuestions(): An abstract method that calculates and return the number of questions. Defined in subclass. · display(): An abstract method that displays all details. Defined in a subclass. 2. Create a class Staff that inherits OnlineQuiz with the following details: Member variables: · staffD // id of the staff string type · staffName // Name of the staff string type · nMCQ // Number of MCQ type questions int type · nTF // Number of true/false type questions int type · nMatch // Number of match type questions int type Member Methods: · Define the parameterized constructor to set the member variables. · Define the method nQuestions(): which calculate and return the total number of questions. Total number of question= nMCQ + nTF +…arrow_forward4) True or False Inheritance allows a subclass to inherit properties and methods from a superclass 5) True or False A class can implement multiple interfaces. 6) What is the syntax for extending a class in Java? class Superclass extends Subclass class Subclass extends Superclass None class Subclass implements Superclassarrow_forward
- Question 2: Recall and apply the concepts of object oriented programming (Java).(i)Create a generic class with a type parameter that simulates drawing an item randomly out of a box. This class could be used for simulating a random drawing. For example, the box might contain Strings representing names written on a slip of paper, or the box might contain Integers representing a random drawing for a lottery based on numeric lottery picks. Create an add method that allows the user of the class to add an object of the specified type along with an isEmpty method that determines whether or not the box is empty. Finally, your class should have a drawItem method that randomly selects an object from the box and returns it. If the user attempts to draw an item out of an empty box, it should return null. Write a main method that tests your class.arrow_forwardExplain briefly the following Object Oriented concepts.(a) Local variable(b) Instance variable(c) Method(d) Inheritance(e) Constructor(f) Encapsulation (getters and setters)(g) Method overloading(h) Method overriding(i) Super keyword(j) Interfacearrow_forwardTrue or False ___(7) An object can be created from an interface. ___(8) An object in a super class can be assigned to a subclass variable. ___(9) Overriding and overloading a method is the same.arrow_forward
- Design a console application that will print a movie ticket for a customer. Make use of an abstractclass named Tickets that contains variables to store the customer name, movie title, customer ageand price of the movie. Create a constructor that accepts the customer name, movie title,customer age and price of the movie as parameters and create get methods for the variables. TheTickets class must implement an iTickets interface that contains the following:public interface iTickets{public void print_tickets();}Create a subclass called TicketSales that extends the Tickets class. The TicketSales class mustcontain a constructor to accept the customer name, movie title, customer age and price of themovie as parameters. Write code for the print_tickets method which displays the customer name,movie title, movie price, discount and final cost due.arrow_forwardWhat key word is used to define a subclass from a super class? Write a Java statement that defines the subclass CSEFaculty class from the superclass CSEEmployee class (which is already defined)arrow_forwardin c++ Assume we have a class called Phone with variables size, weight, type, It has a string array called apps, and a variable called number_of_apps. A subclass is called SumsangPhone, which has a variable called operating_system. Write the constructor for the Sumsang Phone.arrow_forward
- C1 and C2 are classes written in an object-oriented programming language (such as Java, C#, or C++). Which of the following statements are correct if C1 is a superclass of C2? a) C1 is always an abstract class.b) C2 contains all public features defined by C1.c) Each C2 object may be replaced by a C1 object. d) C2 is a subclass of C1.arrow_forwardA new class of objects can be created conveniently by —----------the new class (called the subclass) starts with the characteristics of an existing class (called the superclass), possibly customizing them and adding unique characteristics of its own.arrow_forwardJava Programming Create "Mammal" class as a parent class and "cat" as a child class Mammal(Superclass) Attributes name Methods move() eat() cat (Subclass) Attributes age Methods dispaly() eat() Override eat method in cat subclass. Print something in methods such as in move method you can print “I can move”. Test the inheritance with creating objects and calling parent and child methods. Create object of a child class by passing arguments to the constructor.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Introduction to Classes and Objects - Part 1 (Data Structures & Algorithms #3); Author: CS Dojo;https://www.youtube.com/watch?v=8yjkWGRlUmY;License: Standard YouTube License, CC-BY