Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.

Suppose you have to write a small Java program that catches exceptions with super classes. You are required to use inheritance to create an exception superclass (called ExceptionA) and exception subclasses ExceptionB and ExceptionC; where ExceptionB inherits from ExceptionA and ExceptionC inherits from ExceptionB. Your program must demonstrate that the catch block for type ExceptionA catches exceptions of types ExceptionB and ExceptionC.


Hint: You can use Arithmetic exception like divide by 0 or any similar one.
NOTE: You are required to use Graphical User Input (GUI) to show output on the screen.

Views: 18299

Attachments:

Replies to This Discussion

Sorry folks! im using a system that is out of dated and os xp thats too time consuming, and not supporting any app. nevethless I must give you complete solution. Dont waste your time you have to make your assignment yourself. I'll assist you

NOTE: You are required to use Graphical User Input (GUI) to show output on the screen.

for graphical user interface we use command
import javax.swing.*;

@Anam "

for graphical user interface we use command
import javax.swing.*;" This is only a library or package to include/draw GUI... there are an other steps involve to physical draw it on canvas/form, right now I am busy but will share an idea later. you have shared good idea though, keep it up. :)

@Muhammad Tariq I've the complete coding but need to implement and execute. without execution how can I say this is the complete solution. however if any body share his or her system via team viewer, i can give complete solution

Please send me at my email address. Sherwani05@gmail.com

@Anam You have complete code, very good. How can I help you to execute your code or what kind of difficulties are you facing to execute your code, by the way you can still share your code by attaching files, if you want to.;)

try this code and uplaod error report here if any

import javax.swing.*;
import java.util.Scanner;
public class ExceptionA
{
private int numerator;
private int denominator;
private double quotient;

Public static void main(String[] args)
{
ExceptionA oneTime = new ExceptionA();
oneTime.doIt();
}
public void doIt()
{
try
{
String input = JOptionPane.showInputDialog("Enter Numerator");
Scanner keyboard = new Scanner(System.in);
numerator = keyboard.nextInt();
String input = JOptionPane.showInputDialog("Enter Denominatorr");
Denominator = keyboard.nextInt();

if (denominator == 0)
throw new ExceptionAException();
quotient = numerator /(double) denominator;
System.out.println(numerator + "/" + denominator +"=" + quotient);
JOptionPane.showMessageDialog(null, numerator + "/" + denominator +"=" + quotient);

}
catch (ExceptionAException e)
{
JOptionPane.showMessageDialog(null, "No number can be devisible by Zero");
system.exot(0);
}
}
}

Hi

Can you please connect through teamviewer? Please email me at bwpmukarram@gmail.com

Thanks so much for the help.

@Anam Sorry to say but I really unable to understand this piece of code, Where are ExceptionB and ExceptionC Classes? where is Inheritance? where is pure virtual function? how are you dealing with controls? there is some spelling mistakes e.g system.exot(0); and some upper and lower case problem e.g Public static void main(String[] args).??

bro pls ia ka solution upload kr den pls pls pls

catch is not working.

msg displayed illegal start of exception

RSS

Looking For Something? Search Below

Latest Activity

♥ + Kamli + ♥ liked + M.Tariq Malik's discussion MTH601 Operations Research Assignment 01 Spring 2021 Solution / Discussion
5 minutes ago
+ M.Tariq Malik liked + M.Tariq Malik's discussion BIO303 Biochemistry II Final Term Papers Mega Files - Solved MCQs, Short Notes, Solved Past Papers & More
1 hour ago
+ M.Tariq Malik's 7 discussions were featured
1 hour ago
+ M.Tariq Malik added a discussion to the group BIO303 Biochemistry II
1 hour ago
+ M.Tariq Malik liked + M.Tariq Malik's discussion BIO302 Molecular Biology Final Term Papers Mega Files - Solved MCQs, Short Notes, Solved Past Papers & More
1 hour ago
+ M.Tariq Malik added a discussion to the group BIO302 Molecular Biology
1 hour ago
+ ! ! ! ❣ Sanam ❣ !+ replied to иαвєєℓ αнмє∂'s discussion Kya hal hain ning awam?
1 hour ago
+ M.Tariq Malik liked + M.Tariq Malik's discussion BIO301 Essentials of Genetics Final Term Papers Mega Files - Solved MCQs, Short Notes, Solved Past Papers & More
1 hour ago

VIP Member Badge & Others

How to Get This Badge at Your Profile DP

------------------------------------

Management: Admins ::: Moderators

Other Awards Badges List Moderators Group

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service