Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 11.4, Problem 11.4.1CP
True or false? You can override a private method defined in a superclass.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
You have a method that requires an argument that is an instance of the superclass, and it expects you to provide it. It will function properly if you provide it with an object of a subclass rather than a superclass. Is it even possible? Where is the value in that?
You have a method which requires an argument of type superclass. It will function if you supply a subclass object rather than a superclass object. Is it permissible? What is the purpose?
Assume you have a method expecting the superclass's object to be passed as an argument. In this case, if you give it an object of subclass rather than superclass. Is it acceptable? Why or why not? (Write in maximum 5 lines)
Chapter 11 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 11.2 - True or false? A subclass is subset of a...Ch. 11.2 - What keyword do you use to define a subclass?Ch. 11.2 - What is single inheritance? What is multiple...Ch. 11.3 - What is the output of running the class C in (a)?...Ch. 11.3 - How does a subclass invoke its superclasss...Ch. 11.3 - True or false? When invoking a constructor from a...Ch. 11.4 - True or false? You can override a private method...Ch. 11.4 - True or false? You can override a static method...Ch. 11.4 - How do you explicitly invoke a superclasss...Ch. 11.4 - How do you invoke an overridden superclass method...
Ch. 11.5 - Identify the problems in the following code:...Ch. 11.5 - Prob. 11.5.2CPCh. 11.5 - If a method in a subclass has the same signature...Ch. 11.5 - If a method in a subclass has the same signature...Ch. 11.5 - If a method in a subclass has the same name as a...Ch. 11.5 - Prob. 11.5.6CPCh. 11.7 - Prob. 11.7.1CPCh. 11.8 - Prob. 11.8.1CPCh. 11.8 - Prob. 11.8.2CPCh. 11.8 - Can you assign new int[50], new Integer [50], new...Ch. 11.8 - Prob. 11.8.4CPCh. 11.8 - Show the output of the following code:Ch. 11.8 - Show the output of following program: 1public...Ch. 11.8 - Show the output of following program: public class...Ch. 11.9 - Indicate true or false for the following...Ch. 11.9 - For the GeometricObject and Circle classes in...Ch. 11.9 - Suppose Fruit, Apple, Orange, GoldenDelicious, and...Ch. 11.9 - What is wrong in the following code? 1public class...Ch. 11.10 - Prob. 11.10.1CPCh. 11.11 - Prob. 11.11.1CPCh. 11.11 - Prob. 11.11.2CPCh. 11.11 - Prob. 11.11.3CPCh. 11.11 - Prob. 11.11.4CPCh. 11.11 - Prob. 11.11.5CPCh. 11.12 - Correct errors in the following statements: int[]...Ch. 11.12 - Correct errors in the following statements: int[]...Ch. 11.13 - Prob. 11.13.1CPCh. 11.14 - What modifier should you use on a class so a class...Ch. 11.14 - Prob. 11.14.2CPCh. 11.14 - In the following code, the classes A and B are in...Ch. 11.14 - In the following code, the classes A and B are in...Ch. 11.15 - Prob. 11.15.1CPCh. 11.15 - Indicate true or false for the following...Ch. 11 - Sections 11.211.4 11.1(The Triangle class) Design...Ch. 11 - (Subclasses of Account) In Programming Exercise...Ch. 11 - (Maximum element in ArrayList) Write the following...Ch. 11 - Prob. 11.5PECh. 11 - (Use ArrayList) Write a program that creates an...Ch. 11 - (Shuffle ArrayList) Write the following method...Ch. 11 - (New Account class) An Account class was specified...Ch. 11 - (Largest rows and columns) Write a program that...Ch. 11 - Prob. 11.10PECh. 11 - (Sort ArrayList) Write the following method that...Ch. 11 - (Sum ArrayList) Write the following method that...Ch. 11 - (Remove duplicates) Write a method that removes...Ch. 11 - (Combine two lists) Write a method that returns...Ch. 11 - (Area of a convex polygon) A polygon is convex if...Ch. 11 - Prob. 11.16PECh. 11 - (Algebra: perfect square) Write a program that...Ch. 11 - (ArrayList of Character) Write a method that...Ch. 11 - (Bin packing using first fit) The bin packing...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Define an array of 20 Destination structures (see Checkpoint 8.40). Write statements that store the following i...
Starting Out with C++: Early Objects
Redo (or do for the first time) Programming Project 11 from Chapter 6. Your program should not be hard-coded to...
Problem Solving with C++ (9th Edition)
Fill in the blanks in each of the following: Each class declaration that begins with keyword must be stored in ...
Java How To Program (Early Objects)
Write a program to print the corresponding Celsius to Fahrenheit table.
C Programming Language
Describe a method that can be used to gather a piece of data such as the users age.
Web Development and Design Foundations with HTML5 (8th 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
- You have a method that expects an object from the superclass to be supplied as a parameter. If you offer it a subclass rather than a superclass object, it will work. Is it permitted? What's the point?arrow_forwardYou have a method that takes an argument of type superclass object. You may make it function by providing an object of a subclass rather than a superclass. Is that allowed? I don't see the purpose.arrow_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
- Assume that you write a class Student that does not have a declared superclass. You do not write a toString method. Consider the following lines of code:Student st = new Student();String s = st.toString();Will these lines compile? If so, what exactly will happen when you try to execute?arrow_forwardIn Java Your uncle is trying to keep track of his new-car and used-car lots by writing a Java program. Heneeds your help in setting up his classes.Implement a superclass named Car that contains a price instance variable, a getPrice method, anda 1-parameter constructor. The getPrice method is a simple accessor method that returns the priceinstance variable’s value. The 1-parameter constructor receives a cost parameter and assigns avalue to the price instance variable based on this formula:price = cost * 2;Implement two classes named NewCar and UsedCar; they are both derived from the Carsuperclass. NewCar should contain a color instance variable (the car’s color). UsedCar shouldcontain a mileage instance variable (the car’s odometer reading). The NewCar and UsedCarclasses should each contain a 2-parameter constructor, an equals method, and a toString() method.In the interest of elegance and maintainability, don’t forget to have your subclass constructors callyour superclass constructors…arrow_forwardIn your code, you have a method that takes a superclass instance as a mandatory argument. An instance of a subclass, rather than a superclass object, will suffice. Can we do that, if so? Where is the value in that?arrow_forward
- Looking at the following class definition. What is the name of the superclass? What is the name of the subclass? class Rectangle(BBox):arrow_forwardWrite a java code that: a) Creates an abstract method in a superclass, then overrides it in a subclass. (Only show the methods in both classes). b) Provides a method PrintInfo () that prints your group info and can be used only in classes of the same package. c) Provides a non-overridden area() that calculates area. (choose a shape)arrow_forwardAssume you have a method that expects an object of the superclass to be provided as an argument. This time, instead of a superclass object, you should provide it. Is it OK if I ask? Is there a reason for this or not?arrow_forward
- Overriding a method such as toString(), equals() methods etc in a user defined classarrow_forwardWrite a class named Employee which implements Comparable Interface with name and salary as data fields Add a constructor with argument name and salary. Add getter and Setter for name and salary. Add CompareTo() method for the data Salary. Write a class named Manager which inherits the Employee class. Add an instance variable, named department, of type String. Add a constructor in the subclass class with arguments name, salary, department and a toString() method that prints the manager’s name, department, and salary [Hint: Add a toString( ) method in the super class as well] Create 3 objects of Manager with following arguments 1. (Zayed, 500), 2. ( Ahmed, 700) 3. ( Faisal, 600) Add the above 3 objects into an ArrayLIst object and Sort by Salary and Display. Create an object Employee class with (Zayed, 500,IT) and display the 1. Name 2. Salary 3. Department by using tostring() method.arrow_forwardIn JAVA: A subclasss of you bicycle class for a mountain bicycle, as described in the section: Classes Your brand comes with a water bottle (both the generic and mountain type). Add a new field that will keep the percentage of water remaining in the bottle (1 full, 0 emptty, 0.5 half empty), as described in the section: Declaring member variables. The water bottle is emptty by default. Declare a method to completely fill the water bottle. Declare a method to completely drink the water. No parameters needed. See: Defining methods. Declare a method that will specify how much to fill the water bottle, as a percentage. If the bottle has already that quantity, do nothing. The method must have the same name as above. A parameter is needed. Declare a method that will specify how much to drink from the water as a percentage. The method must have the same name as above. A parameter is needed. Create a new constructor that will specify the initial cadence, gear and water level. See: Providing…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