Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
3rd Edition
ISBN: 9780134038179
Author: Tony Gaddis, Godfrey Muganda
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
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
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 +…
3. The interface Range is defined below:public interface Range{ void setLimits(int x, int y); int getNumber();}
Implementations of Range should exhibit the following behaviour:• The setLimits method should store its parameter values somewhere to serve as the lower and upper limits of the range appropriately.• A call to getValue should return an integer that is always greater than or equal to the lower limit and less than or equal to the upper limit.The class RandomInteger is an implementation of the interface Range. It also has the following features:• It has two fields of int type, low and high, to record the lower and upper limits of the range, respectively.• It has single constructor method that takes two integers and stores them in the appropriate fields. Note: You should make use of the setLimits method.• A call to the method getNumber should return a random number that is always within the range, i.e. greater than or equal to the lower limit and less than or equal to the upper…
Chapter 10 Solutions
Starting Out with Java: From Control Structures through Data Structures (3rd 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
Describe the three types of anomalies that can arise in a table and the negative consequences of each.
Modern Database Management (12th Edition)
What does the Java compiler translate Java source code to?
Starting Out with Java: From Control Structures through Objects (6th 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)
(Convert Celsius to Fahrenheit) Write a program that reads a Celsius degree in a double value from the console,...
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
What is a source program? What is an object program?
Problem Solving with C++ (9th Edition)
Using an example of a component that implements an abstract data type such as a stack or a list, show why it is...
Software Engineering (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
- Design a console application that will capture and print the ingredients for a baking application. Use an abstract class named Recipes that contains variables to store the ingredients, time to make and the difficulty level. Create a constructor that accepts the ingredients, time to make and difficulty level as parameter, and create get methods for the variables. The Recipes class must implement an iRecipes interface that contains the following: public interface iRecipes { public void PrintRecipes(); } Create a subclass called ProcessRecipe that extends the Recipes class. The ProcessRecipes class must contain a constructor to accept the ingredients, time to make and the difficulty level. Next, write code for PrintRecipes() method, which displays the ingredients, time to make and the difficulty level to create. Finally, write a BakingApplication class to instantiate the ProcessRecipes class.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_forwardTrue or False An interface can contain only abstract methods and constants.arrow_forward
- -------Answer code question below--------- Create a class Student with the following characteristics Implements Cloneable interface. Contain two member variables RollNo & Name. Initialize member variable of using the parameterized (2 parameters) constructor. Implement getRollNo and getName methods which returns respective variable values. Input: PGMCA2017 Amit where, The first line contains RollNo. The second line contains Name. Output: PGMCA2017 Amit solution.java code below: *Do not change any other part of the code other than where it says you can.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-------Answer code question below--------- Create a class Student with the following characteristics Implements Cloneable interface. Contain two member variables RollNo & Name. Initialize member variable of using the parameterized (2 parameters) constructor. Implement getRollNo and getName methods which returns respective variable values. Input: PGMCA2017 Amit where, The first line contains RollNo. The second line contains Name. Output PGMCA2017 Amit solution.java code below: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_forwardT/F1. Interface classes cannot be extended but classes that implement interfaces can be extended.arrow_forward
- T/F 1. Interface classes cannot be extended but classes that implement interfaces can be extended.arrow_forwardCreate an interface RateConstants that includes a constant value for the subscription rate that is $15.5. Create a class NewspaperSubsciption that implements the RateConstants interface. A NewspaperSubscription class includes fields for the subscriber’s name and rate. The constructor requires data for name only. The rate should be set to the subscription rate of RateConstants. The name should not contain digits. If the name contains digits, raise an exception InvalidNameException. Create a class name InvalidNameException. The NewspaperSubscription class should throw an exception named InvalidNameException when it receives an invalid subscriber’s name. Create a class PhysicalNewspaperSubcription that extends NewspaperSubscription class. The PhysicalNewspaperSubscription class should have a field for subscription type and a constructor to sets the subscription type to “PhysicalSUB”. The PhysicalNewspaperSubscription class should also have a toString() method to displays all the…arrow_forwardDesign a console application that will capture and print the ingredients for a baking application. Use an abstract class named Recipes that contains variables to store the ingredients, time to make and the difficulty level. Create a constructor that accepts the ingredients, time to make and difficulty level as parameter, and create get methods for the variables. The Recipes class must implement an iRecipes interface that contains the following: public interface iRecipes { public void PrintRecipes(); }.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
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