Find the error in the following class:
public class FindTheError
{
public int square(int number)
{
return number * number;
}
public double square(int number)
{
return number * number;
}
}
Trending nowThis is a popular solution!
Chapter 6 Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Additional Engineering Textbook Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Web Development and Design Foundations with HTML5 (8th Edition)
Thinking Like an Engineer: An Active Learning Approach (4th Edition)
INTERNATIONAL EDITION---Engineering Mechanics: Statics, 14th edition (SI unit)
Concepts Of Programming Languages
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
- QUESTION 9 Public Class Employee { public static int y; Private int age; Public Employee(0{ age=0;} public int get_age() { return age;} Public Class Test { public static void main(String[] args) { Employee q = new Employee(); q.y=2; Employee.y=10; System.out.println("y=" + q.y); a. What is the output of the following code? b. Insert a System.out.println() statement that prints out q's agearrow_forwardWrite the equals method for the following class: B2. public class Car{ String color int numberarrow_forwardI have the following code: public class Length{ private int feet; private int inches; Length() { feet = inches = 0; } Length(int newFeet, int newInches) { feet = newFeet; inches = newInches; } public int getFeet() { return feet; } public void setFeet(int newFeet) { feet = newFeet; } public int getInches() { return inches; } public void setInches(int newInches) { inches = newInches; } public void add(Length otherLength) { int newFeet = this.feet + otherLength.feet; int newInches = this.inches + otherLength.inches; if(newInches >= 12) { newFeet++; newInches -= 12; } this.setFeet(newFeet); this.setInches(newInches); } public Length subtract(Length otherLength) { if(this.feet > otherLength.feet) { int newFeet = feet - otherLength.feet; int newInches = inches - otherLength.inches;…arrow_forward
- correct the codearrow_forwardclass Time { private int hour; private int minute; private int second; public Time( ) { } public Time(int hr , int min, int sec) { } public void setTime(int hr , int min, int sec) { } public void printTime( ) { } public void tick( ) { // tick method defined } } The class Time defines a time object. It represents time (military time) in 2400 hours. 10 AM = 10 hours, 0 minutes and 0 seconds 4 PM = 16 hours, 0 minutes and 0 seconds 7:26PM = 19 hours, 26 miunutes and 0 seconds Assume 0 represents 00 in this case. 1) Implement the two constructor: Time(): will set the instance variables to zero. Time(int hr , int min, int sec): will set the time with parameters passed in. 2) Implement the setTime method to set the instance variables according to the values passed in. 3) Implement the printTime method to print time in hours:minutes:seconds e.g.…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_forward
- public class Accumulator { private int total private String name; public Accummulator (string name , int total) { this .name = name; this .total=total; } } 3. In a main method, create an object of Accumulator with the name as "Mary" and total as 100.arrow_forwardFor the following class, write the code to create two different objects: public class Course{ private String courseCode; private int creditHours public Course(){ this.creditHours= 3; } public Course(String code, int h){ this.courseCode=code; this.creditHours =h; } } javaarrow_forwardIdentify all the members (variables and methods) of a class Company.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