Java: An Introduction to Problem Solving and Programming (8th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
8th Edition
ISBN: 9780134462035
Author: Walter Savitch
Publisher: PEARSON
Question
Book Icon
Chapter 9.2, Problem 16STQ
Program Plan Intro

Program plan:

  • • Create a class named “MessageTooLongException” that extends “Exception”.
    • ○ Define a default constructor that calls the parent class’s method using “super ()” by passing a message.
    • ○ Define a parameterized constructor that calls the parent class’s method using “super ()” by passing a message that is given as the argument.
  • • Create a class named “Main”.
    • ○ Define the “main ()” method.
      • ■ Create an object “e” for the class. Here the exception is thrown using default constructor.
      • ■ Get and print the message using the method “e.getMessage()”.

Blurred answer
Students have asked these similar questions
I am getting this error with the EXCEPTION
public class Test { public static void main (String [] args) { Object circlel = new Circle (); Object circle2 = new Circle (); System.out.println(circlel.equals (circle2)); class Circle { double radius; class Circle { double radius; public boolean equals (Circle circle) { public boolean equals (Object o) { return this.radius = ( (Circle)o).radius; return this.radius = circle.radius;
Derive exception classes from the class you wrote in the previous exercise. Each new class should indicate a specific kind of error. For example, InvalidHourException could be used to indicate that the value entered for an hour was not an integer in the range of 1 to 12. (Also the previous answer was not preferd from the teacher cause its not simple and use def which we arent taken it)

Chapter 9 Solutions

Java: An Introduction to Problem Solving and Programming (8th Edition)

Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education