Question
List and explain various features of java. Explain the words super, static, and final using examples Provide the output of the following program for the
List and explain various features of java.
Explain the words super, static, and final using examples
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");
} }}
Explain both overloading and overriding, and provide an example for each.
Declare a class called employee having employee_id and employee_name as members.
Extend class employee to have a subclass called salary having designation and monthly) salary as members.
Define the following:
- Required constructor.
- A method to find and display all details of employees drawing a salary more than 20,000/-.
- Method main for creating an array for storing these details given as command line arguments and showing usage methods.
Describe abstract class called Shape. This class has three subclasses called: Triangle, Rectangle and Circle. Define one method area () in the abstract class and override this area() in these three subclasses to calculate the area for specific class' object.
Declare a class called coordinate. This is to represent 3 dimensional Cartesian coordinates (x, y and z). Define the following methods:
- Constructor
- Display, to print values of members
- Add_coordinates, to add three such coordinate objects to produce a resultant coordinate object. Generate and handle exceptions if x, y and z coordinate of the result are zero.
- Main, to show use of the above methods.
Write a java application that has three Buttons labeled: Red, Green, and Blue. The java application should have the following:
When clicking on the background, the color should change accordingly and have a label displaying the color selected.
Write an application that creates and starts three threads.
Each thread is instantiated from the same class.
It executes a loop with 10 iterations.
- Each iteration displays the string "HELLO"
- Sleeps for 300 milliseconds.
- The application waits for all the threads to complete & displays the message "Good Bye...".
Draw a use case diagram for a Library Management System.
Answer the following:
- Collection in JAVA.
- Features of Map Interface.
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