Java: An Introduction to Problem Solving and Programming (8th Edition)
8th Edition
ISBN: 9780134462035
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 8.4, Problem 33STQ
Program Plan Intro
“abstract”:
“abstract” is a keyword or modifier, which is used in the case of class and method.
Purpose of “abstract” class:
An “abstract” class is a class which may or may not include abstract methods and cannot be instantiated, but rather can be sub classed or it must serve as a superclass.
The conditions for a class to be considered as legal “abstract” class are mentioned below:
- If a class includes “abstract” methods, then the class must be declared as “abstract”.
- The “abstract” method is declared within the “abstract” class that must be declared without curly braces and followed by a semicolon.
Example of an “abstract” class:
The example of an “abstract” class is mentioned below:
public abstract class GraphicRectangle {
// declare fields
// declare non abstract methods
abstract void drawRectangle();
}
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Hello, can someone pelase help me complete the following:
In JAVA create a cross that takes 2 parameters (width & height) (width must always be equal to height) and prints a cross. Please look at the example printed below:
Write a program that draws a perfect centered star using functional programming. Must use the AffineTransform and Ellipse classes.
Can you have more than one constructor in a program? Write a program to find area of a triangle (when its sides are given) using the concept of " overloaded constructor.
C++
Chapter 8 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Ch. 8.1 - Prob. 1STQCh. 8.1 - Suppose the class SportsCar is a derived class of...Ch. 8.1 - Suppose the class SportsCar is a derived class of...Ch. 8.1 - Can a derived class directly access by name a...Ch. 8.1 - Can a derived class directly invoke a private...Ch. 8.1 - Prob. 6STQCh. 8.1 - Suppose s is an object of the class Student. Base...Ch. 8.2 - Give a complete definition of a class called...Ch. 8.2 - Add a constructor to the class Student that sets...Ch. 8.2 - Rewrite the definition of the method writeoutput...
Ch. 8.2 - Rewrite the definition of the method reset for the...Ch. 8.2 - Can an object be referenced by variables of...Ch. 8.2 - What is the type or types of the variable(s) that...Ch. 8.2 - Prob. 14STQCh. 8.2 - Prob. 15STQCh. 8.2 - Consider the code below, which was discussed in...Ch. 8.2 - Prob. 17STQCh. 8.3 - Prob. 18STQCh. 8.3 - Prob. 19STQCh. 8.3 - Is overloading a method name an example of...Ch. 8.3 - In the following code, will the two invocations of...Ch. 8.3 - In the following code, which definition of...Ch. 8.4 - Prob. 23STQCh. 8.4 - Prob. 24STQCh. 8.4 - Prob. 25STQCh. 8.4 - Prob. 26STQCh. 8.4 - Prob. 27STQCh. 8.4 - Prob. 28STQCh. 8.4 - Are the two definitions of the constructors given...Ch. 8.4 - The private method skipSpaces appears in the...Ch. 8.4 - Describe the implementation of the method drawHere...Ch. 8.4 - Is the following valid if ShapeBaSe is defined as...Ch. 8.4 - Prob. 33STQCh. 8.5 - Prob. 34STQCh. 8.5 - What is an advantage of having the main...Ch. 8.5 - What Java construct allows us to define and...Ch. 8 - Consider a program that will keep track of the...Ch. 8 - Implement your base class for the hierarchy from...Ch. 8 - Draw a hierarchy for the components you might find...Ch. 8 - Suppose we want to implement a drawing program...Ch. 8 - Create a class Square derived from DrawableShape,...Ch. 8 - Create a class SchoolKid that is the base class...Ch. 8 - Derive a class ExaggeratingKid from SchoolKid, as...Ch. 8 - Create an abstract class PayCalculator that has an...Ch. 8 - Derive a class RegularPay from PayCalculator, as...Ch. 8 - Create an abstract class DiscountPolicy. It should...Ch. 8 - Derive a class BulkDiscount from DiscountPolicy,...Ch. 8 - Derive a class BuyNItemsGetOneFree from...Ch. 8 - Prob. 13ECh. 8 - Prob. 14ECh. 8 - Create an interface MessageEncoder that has a...Ch. 8 - Create a class SubstitutionCipher that implements...Ch. 8 - Create a class ShuffleCipher that implements the...Ch. 8 - Define a class named Employee whose objects are...Ch. 8 - Define a class named Doctor whose objects are...Ch. 8 - Create a base class called Vehicle that has the...Ch. 8 - Create a new class called Dog that is derived from...Ch. 8 - Define a class called Diamond that is derived from...Ch. 8 - Prob. 2PPCh. 8 - Prob. 3PPCh. 8 - Prob. 4PPCh. 8 - Create an interface MessageDecoder that has a...Ch. 8 - For this Programming Project, start with...Ch. 8 - Modify the Student class in Listing 8.2 so that it...Ch. 8 - Create a JavaFX application that uses a TextField...Ch. 8 - Prob. 10PP
Knowledge Booster
Similar questions
- Write and test a function to meet this specification.drawFace (center, size, win) center is a Point, size is an int, andwin is a GraphWin. Draws a simple face of the given size in win.Your function can draw a simple smiley (or grim) face. Demonstrate thefunction by writing a program that draws several faces of varying size in asingle window.arrow_forwardIn your own words, what is encapsulation?arrow_forwardHi. I need help. I need this code to be rephrased or reworded so that it won't look like copied? THIS IS THE CONTINUATION OF THE CODE FOR BELOW } for (int i = lastEnd + 1; i < source.length; i++, j++) { swapped[j] = source[i]; } } else { for (int i = 0; i < source.length; i++) { swapped[i] = source[i]; } } System.out.println("Source:"); displayArray(source, 0, source.length - 1); if (firstFound) { System.out.println("First word:"); displayArray(source, firstStart, firstEnd); System.out.println("Last word:"); displayArray(source, lastStart, lastEnd); } System.out.println("After swap:"); displayArray(swapped, 0, swapped.length - 1); } } }arrow_forward
- This is a java assignment. I have attached it in the image file.arrow_forwardWhat is the definition of encapsulation?arrow_forwardI need to do this in python, help. 7- create a class that represents a point on the Cartesian plane. Next, create a class that represents a triangle, reusing the previous class by composition. Finally, write a program that receives the coordinates of the triangle's vertices from the user and prints its perimeter.arrow_forward
- What precisely is meant by the term "encapsulation"?arrow_forwardCheck this code and execute the rectangle class with some modifications: - change to other shapes - add color #include <iostream> using namespace std; class Rectangle { private: double width; double height; public: Rectangle(double w=1, double h=1); double getWidth(); void setWidth(double W); double getHeight(); void setHeight(double h); double getArea(); double getPerimeter();};Rectangle::Rectangle(double w, double h):width(w),height(h) {} double Rectangle::getWidth() { return width; }void Rectangle::setWidth(double w) {width = w; } double Rectangle::getHeight() { return height; } void Rectangle::setHeight(double h) { height = h; } double Rectangle::getArea() { return width*height; } double Rectangle::getPerimeter() { return 2*(width+height); } int main(){ Rectangle r1(4,40); cout<<r1.getArea()<<"\n"<<r1.getPerimeter()<<endl; return 0;}arrow_forwardWrite a function to pull out just Jenny’s eyes, rather than remove the red in them, and paste them into a canvas.arrow_forward
- Given below is a Rectangle class consisting of an upper left coordinate and a lower right coordinate. class Rectangle { int upperLeftX; int upperLeftY; int lowerRightX; int lowerRightY; } Since the upper left coordinate and lower right coordinate comprise of points, how would you modify the definition of the Rectangle class to include these points in your class?arrow_forwardCan someone please help with filling in the blanks of the code for the following in C++? thank you. i will give you upvote /* * pixel should be redesigned as an object, instead of int, with two fields, * as described in the Assignment Specification document */ int **pixel; int size; // number of rows and columns in the image // functions void welcome() { // Optional code goes here } void inputImage() {// Input the image. cout << "Enter image size" << endl; cin >> size; // create and input the pixel array make2dArray(pixel, size + 2, size + 2); cout << "Enter the pixel array in row-major order" << endl; /* * Either ask user for input grid or generate random numbers (zeros and ones) */ for (int i = 1; i <= size; i++) for (int j = 1; j <= size; j++) cin >> pixel[i][j]; } void labelComponents() {// Label the components. // initialize offsets position offset[4]; offset[0].row = 0; offset[0].col = 1;…arrow_forwardThis question is in javaYou are walking along a hiking trail. On this hiking trail, there is elevation marker at every kilometer. The elevation information is represented in an array of integers. For example, if the elevation array is [100, 50, 20, 30, 50, 40], that means at kilometer 0, the elevation is 100 meters; at kilometer 1, the elevation is 50 meters; at kilometer 2, the elevation is 20 meters; at kilometer 3, the elevation is 30 meters; at kilometer 4, the elevation is 50 meters; at kilometer 5, the elevation is 40 meters. a) Write a method called dangerousDescent that determines whether there is a downhill section in the hiking trail with a slope of more than -0.05. The slope is calculated by the rise in elevation over the run in distance. For example, the last kilometer section has a gradient of -0.01 because the rise in elevation is 40 - 50 = -10 meters. The distance covered in 1000 meters. -10 / 1000 = 0.01. Your method should return true if there exists a dangerous…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education