public void makeNoise() { System.out.println("talk"); }//end method makeNoise }//end class Animal public class Dog extends Animal { public void makeNoise() { System.out.println("Bark"); }//end method makeNoise }//end class Dog What would the output of the following be? Explain your answer. Animal animal = new Animal(); animal.makeNoise(); Dog dog = new Dog(); dog.makeNoise(); Animal animaldog = new Dog(); animaldog.makeNoise();
Q: Use Java Programming Language Loan Account Class: Create class LoanAccount. Use a static variable…
A: The java code is given below.
Q: Your task is to implement the following Product class. The description of the class is as follows:…
A: In this question we have to write the JAVA code with the given implementation list. Where, we have…
Q: The following code is valid in Java: public abstract class Shape ( private String name; public…
A: The given code in Java will not work. Therefore, the correct is False.
Q: Create a method "public void giveRaise(int percentage)" in the Employee class. This method should…
A: Since the Programming language is not mentioned in the question, we will answer this question in…
Q: What is output? public abstract class Vehicle {. public abstract void move(int miles); public void…
A: Your answer is given below with an output and explanation.
Q: Q3: (Practical Question) Create a C++ class and name it Vehicle. The class Vehicle has two constant…
A: Answer
Q: (java programing) Define a student class. A student has the following attributes: Firstname: the…
A: import java.io.*; import java.util.*;class student{ string firstname,lastname,gender,status;…
Q: Create a Calculator class that has following methods: sum, multiply, divide, modulus, sin, cos, tan…
A: GIVEN: Using java create class calculator.
Q: (Java) 7.2 Code: Look at the following Person.java class code: class Person{ public String name;…
A: The toString() method is a method in java that is used to print or output the values of an object or…
Q: Java Problem. compile and run the code below: /** A class to test the Door class. */ public…
A: Class definition: A class is a user-defined data type that contains the data members and methods.…
Q: Implement the following classes in Java. Date class which has day(int), month(int) and year(int)…
A: Total 5 classes needs to be maid one each for date, time, datetime, pizzaorder and test class. Date…
Q: public class Ice extends Fire { public void method1() { System.out.print("Ice 1 "); public class…
A: Output of the given program is given below:-
Q: The class RoachPopulation simulates the growth of a roach population.The constructor takes the size…
A: Program code #1:
Q: Rectangle.java /** * Models a rectangle with a width and length. */ 4 public class Rectangle { //…
A: The class Rectangle has following definition: Data members (private): length of type double width…
Q: public class Appliance { public int getVoltage() { return 10; } Appliance.java public interface…
A:
Q: at has following methods: sum, multiply, divide , modulus , sin , cos , tan
A: JAVA code Create a Calculator class that has following methods: sum, multiply, divide , modulus ,…
Q: Modify the Date class below by adding a new method called nextDay() that increments the Date by 1…
A: import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.Calendar; //Date…
Q: the blank in the main method. public class Min { //define your static method here } Write a static…
A: In this question we have to complete the given method in the Java code. For the method where it will…
Q: Consider the following three Java classes: public abstract class Toy { public void makeNoise() {…
A: doll.makeNoise(); doll is an instance of Doll class and it invokes makeNoise() method in Doll…
Q: Consider a class RatingScore that represents a numeric rating for something such as a movie. Its…
A: According to the information given:- We have to take input rating from the user about movie. will…
Q: eSenior = 3; } Answer these questions according to the UML class schema and the code given above.…
A: [JAVA] public class FlightRules {public final static int minHostessCount = 2;public final static int…
Q: Please attach screenshots of code and output screenshots are must needed
A: print("### Question 3: Class and Methods") import math class Circle: ''' A class to represent a…
Q: # Coding - Simulate a robot Write a program that simulates the movements of a robot. The robot can…
A: Let G - advance L- turn left R- Turn right
Q: Assume the class Student implements the Speaker interface from the textbook. Recall that this…
A: HERE IS COMPLETE CODE WITH OUTPUT
Q: Design a class that holds the following personal data: name, address, age, and phone number. Write…
A: class Person {// private data members private String name, address; private int age,…
Q: * Constructor for objects of class SimpleBankAccount public SimpleBankAccount (){ balance- 0.0; ac…
A: Given that:
Q: Write the Circle class:• A Circle has a radius– Add instance variable– 2 constructors – one should…
A: Create a class Circle and define it's instance variable as private type and just declare default…
Q: Complete the partial declaration of Class Car: public class Car { // declare three…
A: this keyword takes value from current object of instance variables. A setter method is always of…
Q: Write a Rectangle class. Its constructor should accept length and width as a parameter. It should…
A: Answer has been explained below:-
Q: Assume the Book class is defined as follows: public class Book{ enum Type type…
A: The Book class is defined as follows: public class Book{ enum Type type {FICTION,NON_FICTION};…
Q: 2. Given the Baby class below: public Class Baby { String name; int birthWeight; } Write an equals…
A: class Baby { public : string name; int birthWeight; };
Q: WRITE THE OUTPUTS OF THE FOLLOWING!!! A.) public class MyClass { static void myMethod() {…
A: JAVA supports the properties of encapsulation and data hiding through the creation of user-defined…
Q: UML for the following Code: public class ProductOrder { private int numBook = 0; private…
A: Answer: We have written UML diagram for given following code
Q: In java language on netbeans design a console application that will print the game sales for a…
A: Here I have created the class Games that implements the interface iGames. In this class, I have…
Q: Problem Description: Write a class Battery that models a rechargeable battery. A battery has a…
A: The program is written in java class Battery{ double capacity; double original_capacity;…
Q: Design a class Parallelogram that contains two private data members: - double length, - double…
A: // C++ program to demonstrate implementation // of Inheritance #include <bits/stdc++.h> using…
Q: Support computing sales tax in the CashRegister class. The tax rate should be supplied when…
A: Note: you have not provided CashRegisterTester.java class file. so, we cannot provide compiled code…
Q: tumLeft and turn Right methods that change the direction of the robot but not the location move…
A: public class Robot{ //declaring instance variables private String name; private int xPos; private…
Q: How many methods and constructors do objects of type Middle have? public class Left{ public Left x;…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: Write the definition of a classTelephone. The class has no constructors and one static method…
A: In this java code we have to define the class Telephone where it will have one static method and…
Q: IN JAVA PLEASE Child Class: Vegetable Write a child class called Vegetable. A vegetable is described…
A: We need to write a Java class for the given scenario.
Q: Find the error(s) in the following class definition: public class TestClass { private int value1;…
A: answer along with screenshots are given below
Q: WRITE THE OUTPUT OF THE PROGRAM AND WRITE THE UML DIAGRAM OF THE PROGRAM : JAVA
A: Output: Item Number:112Name: BookQuantity: 3Price: 125.98Total Cost: 0.0Item Number:101Name:…
Q: FOR JAVA Part I Create a Company class that has at least three properties. Part II Write…
A: we write java code: class Company { int company_id,turnover; String name,address,department,email;…
Q: GIVEN //BookMain.java //This is the client code of Book class public class BookMain{ public static…
A: Note: since your question contain multiple question (having implementation of books and library main…
Q: 1/ Write a BankAccountTester class whose main method constructs a bank account, deposits $1,000,…
A: 1. BankAccountTester.java public class BankAccountTester { public static void main(String…
Q: What does it mean when a method is overloaded?
A: Method overloading Method overloading is a process used in object oriented programming. Polymorphism…
Q: Write a java program to create a class Rectangle. The class has attributes Length and Width. It…
A: Below is the java program with comments and output snapshots.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- Question 13 What is outpout? public class Vehicle { public void drive(){ System.out.println("Driving vehicle"); } } public class Plane extends Vehicle { @Override public void drive(){ System.out.println("Flying plane"); } public static void main(String args[]) { Vehicle myVehicle= = new Plane(); myVehicle.drive(); } Driving vehicle syntax error Flying plane Driving vehicle Flying plane }What is outpout? public class Vehicle { public void drive(){ System.out.println("Driving vehicle"); } public class Plane extends Vehicle { @Override public void drive(){ System.out.println("Flying plane"); } public static void main(String args[]) { Vehicle myVehicle myVehicle.drive(); } } = new Plane(); syntax error Driving vehicle Flying plane Flying plane O Driving vehicleClass Quiz public Quiz (int quesList, int quesMissed) {quesList = this.quesList;quesMissed = this.quesMissed;} private void calculate(){// get the point worth of each question and calculate final scorepointsPerQues = (100/quesList);scoreQuiz = quesList - quesMissed;} Class PassFailQuiz public PassFailQuiz (int quesList, int quesMissed, int scoreQuiz) { super(quesList, quesMissed);} How do I move scoreQuiz from private void calculate() to equal the third constructor value in PassFailQuiz?
- public class Secret private int x; private static int y; public static int count; public int z; public Secret () } X ?t = 2 { public Secret (int a) } { public Secret (int a, int b) } { public String toString() return ("x = " count = " + count); { public static void incrementY () { { 54. How many constructors are present in the class definition above? C. 2 d. 3 b. 1 55. What does the default constructor do in the class definition above? a. Sets the value of x to 0 c. Sets the value of x to 0 and the value of z to 1 d. There is no default constructor. b. Sets the value of z to 1 56. Based on the class definition above, which of the following statements is illegal? Secret.incrementY (); b. Secret.count++3B a. c. Secret. 2++; d. None of these 13// Simulates a simple car with operations to drive and check the odometer.public class SimpleCar { // Number of miles driven private int miles; public SimpleCar(){ miles = 0; } public void drive(int dist){ miles = miles + dist; } public void reverse(int dist){ miles = miles - dist; } public int getOdometer(){ return miles; } public void honkHorn(){ System.out.println("beep beep"); } public void report(){ System.out.println("Car has driven: " + miles + " miles"); } }public class StairViewer public static void main(String(] args) // Step 2: Create a rectangle and draw it as the // top step of the stair // location: (20, 10) // size: (20, 20) 18 // Step 3: Create a rectangle and draw it as the 19 // middle step of the stair 20 // location: below the top step, aligned on left // size: (40, 20) 21 22 23 24 // Step 4: Create a rectangle and draw it as the 25 // bottom step of the stair 26 // location: below the middle step, aligned on left // size: (60, 20) 27 28 29 30 } 31 32
- QUESTION 15 public class numClass { private int a; private static int y = 10; public numClass(int newX) {a=newx; } public void set(int newx) { a=newx; y+=a; } public void setY(int newy) { y=newY; } public static int getY() { return y; } }// end of class public class output { public static void main(String[] args) { numClass one = new numClass(10); numClass two = new numClass (2); try{ one. sety(30); two.set(4); if(one.getY()==30) throw new Exception ("30"); one.setY(40); } catch (Exception e) { two.sety (50); } System.out.println(two.getY()); }// end of main } // end of classpublic class Father { public String name; public int age; // customer name Father(){ name=”Hassan”; age=50;} public void display(){ System.out.println(“Name:”+name); System.out.println(“Age:”+age); } } 1. Based on Figure 3, create a class named Child that inherits the Father class. Declare an instance name location (String) for class Child. 2. Define a constructor in class Child and give an appropriate initial values for the instance (name, age, location). 3. Define a method display () in class Child, execute the display ( ) method in superclass using the keyword super. Method display ( ) in class Child should print the information of name, age and location 4. Create other class named Main for the main method and create 2 objects for the 2 classes (Father and Child). Then execute the display ( ) method for Father and Child. Example of the output as in Figure 4: Father's info: Name: Josh Age: 50 Child's info: Name: Christy Age: 20 Location:…For the following four classes, choose the correct relationship between each pair. public class Room ( private String m type; private double m area; // "Bedroom", "Dining room", etc. // in square feet public Room (String type, double area) m type type; m area = area; public class Person { private String m name; private int m age; public Person (String name, int age) m name = name; m age = age; public class LivingSSpace ( private String m address; private Room[] m rooms; private Person[] m occupants; private int m countRooms; private int m countoccupants; public LivingSpace (String address, int numRooms, int numoccupants) m address = address; new int [numRooms]; = new int [numOceupants]; m rooms %3D D occupants m countRooms = m countOccupants = 0; public void addRoom (String type, double area)
- class Student { private int age = 18; public Student() { age = 19; } } public class Test { public static void main (String[] args){ Student s = new Student(); System.out.println (s.age); } }8. OOPS Theory #6 public class Car { public void horn() { System.out.println("Horn horn"); } } public class Ferrari extends Car { public void horn() { System.out.println("Ferarriiiiii"); } } public static void main(String[] args) { Ferrari ferrari = new Car(); ferrari.horn(); } Pick ONE option Horn horn Ferarriiii Cannot compile Runtime exception Clear Selection 9. OOPS Theory #7 In Java, we can achieve the abstraction by creating the blueprint of an object and only have abstract methods. What do we call this? Pick ONE option Interface Encapsulation Instance Protected Clear SelectionIdentify errors if there is any & after identifying rewrite the code: public class Employce { private String name; private String address; private int number; public abstract double computePay(){ System.out.println("compute the pay"); return 0.0; } public double thanks(){ System.out.println("Thanks");}} public class EmployeeCheck Extends Employee{ public double computePay(){ return number*numer;}}