Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started