Starting Out with Java: From Control Structures through Objects (6th Edition)
6th Edition
ISBN: 9780133957051
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 10, Problem 21MC
You can use a lambda expression to instantiate an object that __________.
- a. that has no constructor.
- b. extends any superclass.
- c. implements a functional interface
- d. does not implement an interface.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
This is object oriented programming
1. 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 +…
Create an interface named Playable that defines a method play requiring no return value. Play just displays the string “Play me.” Create a class named Instrument that implements playable that contains a private member name but does not implement the play of Playable.
a. define setter and getter for name
b. define a constructor that accepts a String name argument to be assigned to the name attribute of the class
c. override equals of the object for this class
d. override toString of an object for this class
3. Implement a concrete subclass of an instrument named Guitar.
a. Create a constructor similar to the default constructor provided by the system. See to it that the superclass object is created.
b. See to it that the abstract method is also implemented
c. override equals of the object for this class
d. override toString of the object for this class
Chapter 10 Solutions
Starting Out with Java: From Control Structures through Objects (6th Edition)
Ch. 10.1 - Here is the first line of a class declaration....Ch. 10.1 - Look at the following class declarations and...Ch. 10.1 - Class B extends class A. (Class A is the...Ch. 10.2 - Prob. 10.4CPCh. 10.2 - Look at the following classes: public class Ground...Ch. 10.3 - Under what circumstances would a subclass need to...Ch. 10.3 - How can a subclass method call an overridden...Ch. 10.3 - If a method in a subclass has the same signature...Ch. 10.3 - If a method in a subclass has the same name as a...Ch. 10.3 - Prob. 10.10CP
Ch. 10.4 - When a class member is declared as protected, what...Ch. 10.4 - What is the difference between private members and...Ch. 10.4 - Why should you avoid making class members...Ch. 10.4 - Prob. 10.14CPCh. 10.4 - Why is it easy to give package access to a class...Ch. 10.6 - Look at the following class definition: public...Ch. 10.6 - When you create a class, it automatically has a...Ch. 10.7 - Recall the Rectangle and Cube classes discussed...Ch. 10.8 - Prob. 10.19CPCh. 10.8 - If a subclass extends a superclass with an...Ch. 10.8 - What is the purpose of an abstract class?Ch. 10.8 - If a class is defined as abstract, what can you...Ch. 10.9 - Prob. 10.23CPCh. 10.9 - Prob. 10.24CPCh. 10.9 - Prob. 10.25CPCh. 10.9 - Prob. 10.26CPCh. 10.9 - Prob. 10.27CPCh. 10.9 - Prob. 10.28CPCh. 10 - In an inheritance relationship, this is the...Ch. 10 - In an inheritance relationship, this is the...Ch. 10 - This key word indicates that a class inherits from...Ch. 10 - A subclass does not have access to these...Ch. 10 - This key word refers to an objects superclass. a....Ch. 10 - In a subclass constructor, a call to the...Ch. 10 - The following is an explicit call to the...Ch. 10 - A method in a subclass that has the same signature...Ch. 10 - A method in a subclass having the same name as a...Ch. 10 - These superclass members are accessible to...Ch. 10 - Prob. 11MCCh. 10 - With this type of binding, the Java Virtual...Ch. 10 - This operator can be used to determine whether a...Ch. 10 - When a class implements an interface, it must...Ch. 10 - Prob. 15MCCh. 10 - Prob. 16MCCh. 10 - Abstract classes cannot ___________. a. be used as...Ch. 10 - You use the __________ operator to define an...Ch. 10 - Prob. 19MCCh. 10 - Prob. 20MCCh. 10 - You can use a lambda expression to instantiate an...Ch. 10 - True or False: Constructors are not inherited.Ch. 10 - True or False: in a subclass, a call to the...Ch. 10 - True or False: If a subclass constructor does not...Ch. 10 - True or False: An object of a superclass can...Ch. 10 - True or False: The superclass constructor always...Ch. 10 - True or False: When a method is declared with the...Ch. 10 - True or False: A superclass has a member with...Ch. 10 - True or False: A superclass reference variable can...Ch. 10 - True or False: A subclass reference variable can...Ch. 10 - True or False: When a class contains an abstract...Ch. 10 - True or False: A class may only implement one...Ch. 10 - True or False: By default all members of an...Ch. 10 - // Superclass public class Vehicle { (Member...Ch. 10 - // Superclass public class Vehicle { private...Ch. 10 - // Superclass public class Vehicle { private...Ch. 10 - // Superclass public class Vehicle { public...Ch. 10 - Write the first line of the definition for a...Ch. 10 - Look at the following code, which is the first...Ch. 10 - Write the declaration for class B. The classs...Ch. 10 - Write the statement that calls a superclass...Ch. 10 - A superclass has the following method: public void...Ch. 10 - A superclass has the following abstract method:...Ch. 10 - Prob. 7AWCh. 10 - Prob. 8AWCh. 10 - Look at the following interface: public interface...Ch. 10 - Prob. 1SACh. 10 - A program uses two classes: Animal and Dog. Which...Ch. 10 - What is the superclass and what is the subclass in...Ch. 10 - What is the difference between a protected class...Ch. 10 - Can a subclass ever directly access the private...Ch. 10 - Which constructor is called first, that of the...Ch. 10 - What is the difference between overriding a...Ch. 10 - Prob. 8SACh. 10 - Prob. 9SACh. 10 - Prob. 10SACh. 10 - What is an. abstract class?Ch. 10 - Prob. 12SACh. 10 - When you instantiate an anonymous inner class, the...Ch. 10 - Prob. 14SACh. 10 - Prob. 15SACh. 10 - Employee and ProductionWorker Classes Design a...Ch. 10 - ShiftSupervisor Class In a particular factory, a...Ch. 10 - TeamLeader Class In a particular factory, a team...Ch. 10 - Essay Class Design an Essay class that extends the...Ch. 10 - Course Grades In a course, a teacher gives the...Ch. 10 - Analyzable Interface Modify the CourseGrades class...Ch. 10 - Person and Customer Classes Design a class named...Ch. 10 - PreferredCustomer Class A retail store has a...Ch. 10 - BankAccount and SavingsAccount Classes Design an...Ch. 10 - Ship, CruiseShip, and CargoShip Classes Design a...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
In each case, the beam is subjected to the loadings shown. Draw the free-body diagram of the beam, and sketch t...
Mechanics of Materials (10th Edition)
(Greatest Common Divisor) The greatest common divisor (GCD) of two integers is the largest integer that evenly ...
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
For each of the following numeric formats, identify the format string used as the input parameter when calling ...
Starting Out With Visual Basic (8th Edition)
The following statement subtracts 1 from x: x = x 1
Starting Out with Python (4th Edition)
Broaching machines are simpler in a basic design than most other machine tools. Why is this?
Degarmo's Materials And Processes In Manufacturing
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
- in javaarrow_forwardin C++arrow_forwardWrite a Java program that implements the following classes: Show - name: String - timesWatched: int - rate: double - maxRate: int =5 + Show() + Show(name: String) + getName(): String + setName(name:String):void + getRate(): double + getTimesWatched(): int + getMaxRate(): int + updateRate(): void + toString(): String Movie Series - duration: int - productionYear: int + Movie() + Movie(name: String, duration: int, productionYear:int) + toString(): String + getDuration(): int + getProductionYear(): int - numOfEpisodes: int episodeDuration: int + Series() + Series(name: String, numOfEpisodes:int, episodeDuration: int) + toString():String + getNumOfEpisodes(): int + getEpisodeDuration(): int In the Show class: - The timesWatched and rate must be initialized to zero. - The no-arg constructor reads the name from the user. - The Show(name: String) constructor initializes the data field name with the value of the passed parameter пате. - The updateRate method reads the user rate and re-computes…arrow_forward
- Define an interface as follows: Interface Bicycle { // wheel revolutions per minute void changeCadence(int newValue); //will change value of candence to new value void changeGear (int newValue); changes gear of car void speedUp(int increment); //increments speed of car by adding new Value to existing speed void applyBrakes(int decrement); }//decease car speed by subtracting value from speed. To implement this interface, the name of your class would change (to a particular brand of bicycle, for example, such as ACMEBicycle, KEYOBicycle), and you'd use the implements keyword in the class declaration: class ACMEBicycle implements Bicycle{ int cadence = 0; int speed = 0; int gear = 1; //methods of interface } These clases will implements the abstract method of interface and provide definitions according to them. Now in main class you will ask user what kind of bicycle he/she wants create object of that class, then asks user for options 1. Change cadence 2. Change gear 3. Speed…arrow_forwardCalculator Class In the file Calculator.java, write a class called Calculator that emulates basic functions of a calculator: add, subtract, multiply, divide, and clear. The class has one private member field called value for the calculator's current value. Implement the following Constructor and instance methods as listed below: public Calculator() - Constructor method to set the member field to 0.0 public void add(double val) - add the parameter to the member field public void subtract(double val) - subtract the parameter from the member field public void multiply(double val) - multiply the member field by the parameter public void divide(double val) - divide the member field by the parameter public void clear( ) - set the member field to 0.0 public double getValue( ) - return the member field Given two double input values num1 and num2, the program outputs the following values: The initial value of the instance field, value The value after adding num1 The value after…arrow_forward1. Design a Java JFood class for a food which implements both cloneable and comparable interfaces The class should have the following private member variables: mId: an integer that holds the food ID mName: a string that holds the food name mQuantity: an integer that holds quantity of servings of food mCalory: a double that holds calory of one serving of food mIngredients: an array of String that holds the names of all ingredients and its size is three and the class should have the following public member functions: default constructor: initializes the product to some default one constructor #2: accepts id, name, quantity, calory and ingredients as arguments. The method should set these values to the appropriate instance variables setFood: accepts quantity, calory and ingredients as arguments. The method should set the arguments to the appropriate instance variables. Please note ingredients need be set as deep copy. Five respective get functions to retrieve the five instance…arrow_forward
- Software Requirements: • Latest version of NetBeans IDE • Java Development Kit (JDK) 8 Procedure: 1. Create a public class named Monday. This class shall contain the main method. 2. Define an interface (without a modifier) named Alarm. This interface shall contain two (2) void methods named setAlarm() and showAlarm(). The setAlarm() method has a String parameter named time. 3. Add two (2) classes without modifiers named Weekday (abstract) and Monday. 4. For the Weekday class, implement the Alarm interface. Leave this class empty. 5. Set Weekday as the parent of Monday. Import Scanner from java.util and LocalTime from java.time. For showAlarm(), add these two (2) statements: LocalTime alarm = LocalTime .parse(time); LocalTime now = LocalTime.now(); Explanation: parse() converts String to time, while now() obtains the current time. 7. The output shall ask the user to enter the time for the alarm. If the time entered is past the current time, then display "Alarm is set for tomorrow!";…arrow_forwardIn JavaScript create an object called a monster class. The monster class should have a language argument string and a stomach represented by an array. The monster should support functions eat() and speak(). Class notation is needed to define the Monster's object interface. The eat() function will store whatever argument is passed to it and return what it has eaten. The speak() function will return the string passed to it. After completing the above Great an object called Gremlin that extends the Monster interface and takes the same argument. The gremlin should: inherit how the monster eats speak differently in that any words passed as arguments to the monster above are replaced by the word "gar" which repeats based on the length of the string passed in monster speak() above.arrow_forwardJava code please 1. Appliance and TV by CodeChum Admin Create a class called Appliance. An appliance simply has a: brand (a text) a cost (a monetary value) a power status (ON or OFF) Power status, brand and cost should not be accessible out the class or its hierarchy of inheritance. It has one constructor that accepts a string and double for the brand and cost respectively (prints "Appliance Constructor" as well). It sets the power status to OFF. Apart from the getters, it also has two public methods, power(), and toString(). power() turns on the appliance if it is off, otherwise, if it is on, it turns the appliance off. toString() simple returns a String object representing the Appliance in this format ("Brand: xxxx, Cost: PhP xxxx.xx, Power: xx"). Create another class called Television. Television is an Appliance. It only has the following additional private attributes: type (whether Smart or Non-Smart) volume (0 - 100) channel (1 - 100) It should have the following…arrow_forward
- in javaarrow_forwardinheritance in javaarrow_forwardConstructors in Java Create a constructor for the Phone class that accepts three values: brand storage price Then, ask the user for the values of these attributes. Use the constructor to create the object and finally, print the values of the attributes. Inputs 1. Brand 2. Storage 3. Price Sample Output Brand: TestBrand Storage: 128 Price: 50000 TestBrand has a memory of 128 GB and a price of Php50000!arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Memory Management Tutorial in Java | Java Stack vs Heap | Java Training | Edureka; Author: edureka!;https://www.youtube.com/watch?v=fM8yj93X80s;License: Standard YouTube License, CC-BY