Complete the code for the following program. You are provided with an abstract class called abst. Create a class that will be a child of abst and it will be called usesAbst. Your program will have an int variable called value, and all the appropriate methods, as well 2 constructors. The first constructor will simply set the variable value to 0. The second constructor will set the variable value to equal a passed in parameter. You do not have to comment your code.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 2PE
icon
Related questions
Question
Complete the code for the following program. You are provided with an abstract
class called abst. Create a class that will be a child of abst and it will be called
usesAbst. Your program will have an int variable called value, and all the
appropriate methods, as well 2 constructors. The first constructor will simply set
the variable value to 0. The second constructor will set the variable value to equal
a passed in parameter. You do not have to comment your code.
public abstract class abst{
public abst () {
}
//Outputs to the screen the message Hello
public abstract void sayHello ();
//returns the stored int value
public abstract int getValue ();
//sets the int value to x
public abstract void setValue (int x);
//Outputs to the screen the message Another method
public void output () {
System.out.println("Another method");
public String tostring () {
return "This is an abstract class";
}
Transcribed Image Text:Complete the code for the following program. You are provided with an abstract class called abst. Create a class that will be a child of abst and it will be called usesAbst. Your program will have an int variable called value, and all the appropriate methods, as well 2 constructors. The first constructor will simply set the variable value to 0. The second constructor will set the variable value to equal a passed in parameter. You do not have to comment your code. public abstract class abst{ public abst () { } //Outputs to the screen the message Hello public abstract void sayHello (); //returns the stored int value public abstract int getValue (); //sets the int value to x public abstract void setValue (int x); //Outputs to the screen the message Another method public void output () { System.out.println("Another method"); public String tostring () { return "This is an abstract class"; }
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Class
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning