Look at the following pseudocode class definitions:
Class Vegetable
Public Module message ()
Display “I’m a vegetable.”
End Module
End Class
Class Potato Extends Vegetable
Public Module message ()
Display “I’m a potato.”
End Module
End Class
Given these class definitions, what will the following pseudocode display?
Declare Vegetable v
Declare Potato p
Set v = New Potato ()
Set p = New Potato()
Call v. message()
Call p. message()
Want to see the full answer?
Check out a sample textbook solutionChapter 14 Solutions
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Additional Engineering Textbook Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Starting Out with C++ from Control Structures to Objects (8th Edition)
C Programming Language
Starting Out With Visual Basic (8th Edition)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
- Java A class always has a constructor that does not take any parameters even if there are other constructors in the class that take parameters. Choose one of the options:TrueFalsearrow_forwardJava language pls write a main program of the language class given below and make sure that your output matches with the one given below. Language.java public final class Language { // // Static Data Fields // private static final String defaultAlienSound = "~ ąļīæń ~ "; // Default // // Instance Data Fields // // // Constructors // public Language() { } public Language(String language) { switch (language.toLowerCase()) { case "alien" -> this.populateAlienPhrases(); // Supported case "chinese" -> this.populateChinesePhrases(); // Future implementation case "french" -> this.populateFrenchPhrases(); // Future implementation case "spanish" -> this.populateSpanishPhrases(); // Future implementation case "future" -> this.populateYourLanguagePhrases(); // Future implementation default -> this.populateEnglishPhrases();…arrow_forwardPrograming language Java. Define a class that represents a smartphone and in particular its battery. The battery has a capacity in mAH (milliamp-hours). This would be a parameter to yourconstructor. Several features of the phone consume battery power: the screen, voicecalling, wifi, and Bluetooth. These can be on or off. When on, they use power asgiven in the following table:screen 500 mAvoice 300 mAwifi 200 mABluetooth 100 mAThe battery life (in hours) of the phone is its capacity (in mAH) divided by the totalpower use of all the features that are turned on (in mA). Your class should have amethod that computes and returns the battery life given the current settings of thefeatures. The purpose of this question is for you to get practice with objects havingboth state and behavior. Hint: you should use boolean instance variables to representthe states of each of the four features outlined above. Look up a phone’s battery capacity (for example, 2200 mAH) and write a short mainmethod which…arrow_forward
- Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A,B,C,D,E" is correct. Each question has one correct answer. Thank you. Part 1 - 5. In Java, inheritance uses __ relationship. A. is-aB. part-ofC. has-aD. member-ofE. None of the options Part 2 - 6. Given the following code, the output is __. class Apple { int x = 15; }class Banana extends Apple { int x = 25; }public class Sample { public static void main(String[] args) {Apple a1 = new Banana(); System.out.println(a1.x); }} A. Compiler errorB. 25C. 15D. 0E. None of the optionsarrow_forwardC++ Personal Information Class: Design a class that holds the following personal data: name, age, and phone number. Write appropriate accessor and mutator functions. Demonstrate the class by writing a program that creates three instances of it. One instance should hold your information, and the other two should hold your friend's or family member's information.arrow_forwardwrite c++ code for Design a class named Computer that holds the make, model, and amount of memory of a computer. Include methods to set the values for each data field, and include a method that displays all the values for each field. Create the class diagram and write the pseudocode that defines the class. // Pseudocode PLD Chapter 10 #4 pg. 461// Start// Declarations// Computer myComputer// string make// string model// int memory// output "Please enter the Make: "// input make// output "Please enter the Model: "// input model// output "Please enter the Amount of Memory: "// input memory// Set the Make for myComputer// Set the Model for myComputer// Set the Amount of Memory for myComputer// output "Make: ", myComputer.getMake()// output "Model: ", myComputer.getModel()// output "Amount of Memory: ", myComputer.getMemory()// Stop header #include <string>using namespace std;#ifndef _Computer#define _Computerclass Computer{private:string make; // computer makestring model; //…arrow_forward
- A constructor_______________ parameters. Select the correct answer: a) can receive b)cannot receive c) must receive d) can receive a maximum of 10arrow_forwardCreate a class “Student” with data members such as roll number, name and branch. Create another class “Exam” for storing marks of three subjects. Derive a new class “Result” from “Student” and “Exam” class with data members such as total and average. Display the values of all the data members. Develop a C++ program to model the above relationships.Also include comments for the code. Test cases Private – Input 1000 ABC CSE 90 80 70 Output 240 80 Public – Input 2000 DEF IT 25 30 35 Output 90 30arrow_forwardC++ language (Composition problem) Given the following two classes A and B, where all member functions have been fully implemented inline. class A { public: void f(int arg) { data = arg; } int g() { return data; } private: int data; }; class B { public: A x; }; int main() { B obj; // ... write code here return 0; } a. Insert the code in the main() function that assigns integer value 99 to the “data” member of obj, which is a B class object). b.Write the code to display the value (i.e., 99) that has just been assigned to the obj. c. Note that only a single object obj of B class is declared. How many times are constructors called? If more than one constructor is called, in what order are they called?arrow_forward
- Look at the following class declarations: class Plant { public virtual void Message() { MessageBox.Show("I'm a plant."); } } class Tree : Plant { public override void Message() { MessageBox.Show("I'm a tree."); } } Given these class definitions, what will the following code display? Plant p = new Tree(); p.Message();arrow_forwardon JAVA language Define a class named Wall. The class should have two private double variables, one to store the length of the Wall and another to store the height ._Create adefault constructor that sets the length& height to 0, create a second constructor with input parameters for the of the data variables and third copy constructor.Add accessor and mutator functions to read and set both variables Add another function that returns the area of the Wall as double .Write program that tests all your constructors and functions for at least three different Wall objectsarrow_forwardLanguage: C++Define a base class shape that includes protected data members for area and volume of a shape, public methods for computing area and volume of a shape, and a display function to display the information about an object. Derive a class point from the shape class. This point class contains two protected data members that hold the position of point. Provide no argument and 2-argument constructors. Override the appropriate functions of base class. Derive a class Circle publicly from the point class. This class has a protected data member ofradius. Provide a no-argument constructor to initialize the fields to some fixed values. Provide a 3-argument constructor to initialize the data members of Circle class to the values sent from outside. Override the methods of base class as required. Derive another class Cylinder from the Circle class. Provide a protected data member for height of cylinder. Provide a no-argument constructor for initializing the data members to default values.…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education