Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. Provide the output of the following program for the values of y=0 and y=2: public class Test { public static void main(String args[]) {

2. Provide the output of the following program for the values of y=0 and y=2: public class Test { public static void main(String args[]) { try { System.out.println("calling method a"); a(); System.out.println("return from method a"); } catch(ArithmeticException e) { System.out.println("main: catch"); } finally { System.out.println("main: finally"); } } public static void a() { try { int x=8,y=0; int z=x/y; System.out.println("value of z="+z); } catch(NumberFormatException e) { System.out.println("method a:catch"); } finally { System.out.println("method a:finally"); } }}

3. Explain both overloading and overriding, and provide an example for each.

a. Declare a class called employee having employee_id and employee_name as members. b. Extend class employee to have a subclass called salary having designation and monthly) salary as members. c. Define the following: i. Required constructor. ii. A method to find and display all details of employees drawing a salary more than 20,000/-. iii. Method main for creating an array for storing these details given as command line arguments and showing usage methods.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Explain the forces that influence how people handle conflict

Answered: 1 week ago

Question

1. Discuss the potential legal issues that relate to training.

Answered: 1 week ago

Question

3. Design a program for preparing for cross-cultural assignments.

Answered: 1 week ago

Question

2. Develop a program for effectively managing diversity.

Answered: 1 week ago