Concept explainers
Look at the following classes:
public class Ground
{
public Ground()
{
System.out.println(“You are on the ground.”);
}
public Ground(String groundColor)
{
System.out.println(“The ground is ” + groundColor);
}
}
public class Sky extends Ground
{
public Sky()
{
System.out.println(“You are in the sky.”);
}
public Sky(String skyColor)
{
super(“green”);
System.out.println(“The sky is “ + skyColor);
}
}
What will the following
public class Checkpoint
{
public static void main(String[] args)
{
Sky object = new Sky(“blue”);
}
}
Want to see the full answer?
Check out a sample textbook solutionChapter 10 Solutions
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Additional Engineering Textbook Solutions
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
SURVEY OF OPERATING SYSTEMS
Concepts Of Programming Languages
BASIC BIOMECHANICS
Elementary Surveying: An Introduction To Geomatics (15th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
- public class Cylinder { public void smoothen() { } } } public abstract class Vessel implements Steerable { private Engine e; } System.out.println("Smoothening.."); public Engine getEngine() { return e; } public void setEngine (Engine e) { this.e = e; } public abstract void turnOn(); public class Engine { private Cylinder [] y; private int cyls = 1; static final int maxCylinders = 12; public void addCylinder (Cylinder y) { if (cylsarrow_forwardpublic class A { public void funl () { System.out.println ("Al"); } public class B extends A { @Override public void funl () { super.fun1 () ; System.out.println ("B1"); public void fun2 () { System.out.println ("B2"); public class C extends B { @Override public void funl () { System.out.println ("C1");arrow_forwardBased on Figure 3, create a class named Child that inherits the Father class. Declare an instance name location (String) for class Child. [3 marks]arrow_forwardFind the error(s) in the following class definition: public class Circle private double radius; public double setRadius(double a) { radius = a; public void getRadius() { return radius;arrow_forwardpublic class Base { public void PrintName() { System.out.println("Base"); } static void PrintClass() { System.out.println("ClassBase"); } private void PrintPrivate() { System.out.println("PrintPrivate"); } class Derived extends Base { public void PrintName() { System.out.println("Derived"); } static void PrintClass() { System.out.println("ClassDerived"); } private void PrintPrivate() { System.out.println("PrintDerived"); } public static void main(String[] args) { Base x = new Derived(); Derived y = new Derived(); x.PrintClass(); y.PrintPrivate(); x.PrintName();arrow_forwardpublic class Story { public Story() { System.out.println("STORY"); } } public class Folklore extends Story { public Folklore () { System.out.println("FOLKLORE"); } } public class FairyTale extends Folklore { public FairyTale () { super (); System.out.println("FAIRYTALE"); } } Given the class definitions above, what is printed to the console when the following lines of code are executed? Assume the code compiles and runs (i.e. ignore typos). Folklore f = new Folklore(); FairyTale ft = new FairyTale(); STORY FOLKLORE STORY FOLKLORE FAIRYTALE STORY FOLKLORE FAIRYTALE FOLKLORE FAIRYTALE STORY FOLKLORE STORY FAIRYTALEarrow_forwardexplain and answer what kind of Design Pattern is the following: public class Date { private String month; private int day; private int year; public Date(String month, int day, int year){ this.setMonth(month); this.day =day; this.setYear(year); } public Date(String month, int year){ this.setMonth(month); this.setYear(year); } public int getYear() { return year; } public void setYear(int year) { this.year = year; } public String getMonth() { return month; } public void setMonth(String month) { this.month = month; } public int getDay() { return day; } public void setDay(int day) { this.day = day; } public String MonthConvert(String month){ String MonthNumber = "-1"; switch(month.toLowerCase()){ case "jan": case "january":case "1":case "01": MonthNumber = "01"; break; case "feb": case "febuary":case "2":case "02": MonthNumber = "02"; break; case "mar": case "march":case "3":case "03": MonthNumber = "03"; break; case "apr": case "april":case "4":case "04": MonthNumber = "04";…arrow_forwardBelow is a definition for a Dumbbell class: public class Dumbbell { private double weight; // in pounds public Dumbbell() { weight = 1.0; }public Dumbbell(double w) {weight = w;} public void setWeight(double newWeight) { weight = newWeight; } public double getWeight() { return weight; }public lift() {System.out.println("You did 1 rep with the " + weight + " lb dumbbell.");}} Modify the setWeight method to check that the new weight parameter is between 1 and 50 pounds. If the new weight is less than 1 pound, set it to 1 pound instead. If the new weight is greater than 50 pounds, set it to 50 pounds instead. Show the modified method in your post. Add a second lift() method which takes an integer parameter signifying how many reps to do with the dumbbell. Print an appropriate message for the number of reps performed, similar to the message in the existing lift() method. If the number of reps is 20 or more, also print out the statement "Whew, what a workout!"…arrow_forwardclass Animal { public void animalSound() { System.out.println("Animals make sounds lol"); }} class Pig extends Animal { public void animalSound() { System.out.println("The pig goes oink"); }} class Dog extends Animal { public void animalSound() { System.out.println("The dog goes woof"); }} public class Main { public static void main(String[] args) { Animal myAnimal = new Animal(); Animal myPig = new Pig(); Animal myDog = new Dog(); // animal class method called myAnimal.animalSound(); // Pig class method called myPig.animalSound(); // Dog class method called myDog.animalSound(); }} I created a polymorphism program and I want to know is which is the parent class and what is the child...arrow_forwardClass 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?arrow_forwardIdentify 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;}}arrow_forwardIs this TRUE or FALSE? IF FALSE WHAT IS THE CORRECT ANSWER?arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT