0% found this document useful (0 votes)
6 views5 pages

Java Programming Applications and Concepts

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views5 pages

Java Programming Applications and Concepts

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

Batch- I

1. Write an application in Java that prompts the user for the radius of a circle and uses a
method called circleArea to calculate the area of the circle and uses a method
circlePerimeter to calculate the perimeter of the circle.

2. Write an application in Java to create a super class Employee with information first
name & last name and methods getFirstName(), getLastName() derive the sub-
classes ContractEmployee and RegularEmployee with the information about
department, designation & method displayFullName() , getDepartment(), getDesig() to
print the salary and to set department name & designation of the corresponding sub-
class objects respectively.

3. Write an application in Java to create a super class Vehicle with information vehicle
number,insurance number,color and methods getConsumption()
displayConsumption(). Derive the sub-classes TwoWheeler and FourWheeler with
method maintenance() and average() to print the maintenance and average of vehicle.

4. Using Java create an abstract class Shape which calculate the area and volume of 2-d
and 3-d shapes with methods getArea() and getVolume(). Reuse this class to
calculate the area and volume of square ,circle ,cube and sphere.

5. In Java, create an abstract class Employee with methods getAmount() which displays
the amount paid to employee. Reuse this class to calculate the amount to be paid to
WeeklyEmployeed and HourlyEmployee according to no. of hours and total hours for
HourlyEmployee and no. of weeks and total weeks for WeeklyEmployee.
6. Create an Interface Vehicle with method getColor(),getNumber(), getConsumption()
calculate the fuel consumed, name and color for TwoWheeler and Four Wheeler By
implementing interface Vehicle.

7. Create an Interface StudentFee with method


getAmount(),getFirstName(),getLastName(), getAddress(), getContact(). Calculate the
amount paid by the Hostler and NonHostler student by implementing interface Student
Fee.

8. Write a Java program to create package called dept. Create four classes as CSE,
ECE, ME and CE add methods in each class which can display subject names of your
respect year. access this package classes from main class.

9. Create a class First (With display()), Second (With show()) in one package (myp),
create a class Third (With show()) in second package (mys). Create a class Test
(main()) & call all the methods in different classes.

10. Write a Java program to implement i) Null pointer exception, ii) String Index Out Of
Bounds Exception iii) FileNotFound and iv) InputMismatch Exception.

11. Create a class to handle a user defined exception (Name: Your preferred name), to
check if user can attend the university exam. If the user says he/she is tested corona
positive, user is not eligible to attend the exam. If the user says he/she is tested
corona negative, user is eligible to attend the exam.

12. Create an abstract class Eatable with an abstract method eat(), Create a child class
Fruit (Make it as abstract) add abstract method taste(), Create a child class to Fruit as
nameofFruit (class name) and call the methods eat, taste in a test class.
13. Develop a Java program for generating three threads to perform the following
Operations: i) Accept ‘N’ numbers ii) Print the greatest number and iii)Print the
smallest number.

14. Write a Java program to rethrow an exception – Define methods one() & two().
Method two() should initially throw an exception. Method one() should call two(), catch
the exception and rethrow it Call one() from main() and catch the rethrown.

15. Create an Interface payable with method getAmount ().Calculate the amount to be
paid to Invoice and Employee by implementing Interface.

Batch-II

1. Solve problem by using sequential search algorithms (Selection, insertion)

2. Solve problem by using binary search sorting algorithms (Selection, insertion)

3. Solve problem by using quadratic sorting algorithms. (Selection, insertion)

4. Develop stack and queue data structures using classes and objects.

5. Develop a java application with an employee class with members for generate pay

Slip using inheritance.

6. Write a java program to create abstract class for calculating area of different shape.

7. Write a java program to create interface for calculating area of different shape.

8. write a java program for implementing user defined exceptions handling.


9. write a java program for implementing multi-threaded application.

10. write a java program that reads a file name from the user, displays information about

whether the file exists, whether the file is readable, or writable, the type of file and the length of the
file in bytes.

11. write a java program for implementing generic class.

12. Design a calculator as a mini project using event driven programming paradigm of

java with the following options a) Decimal Manipulations b) Scientific Manipulations.

13. Develop queue data structures using classes and objects.

14. Write a Java Program to create an abstract class named sum of Two and sum of Three. Perform
addition of two numbers and addition of three numbers

15. Write a program to Check Prime Number using Interface.

16. Write a Java program to find the sum value of two given type of elements using a generic class.

17. Write a java program that implements a multithread application that has three threads. First thread
generates random integer every one second and if the value is odd, second thread computes the
square of the number and prints the value is even, the third will print the cube of the number.

18. Create a Java Application to calculate GPA for 5 subjects using the marks of the subject
and credits of the subject and implement a user defined exception for subject mark, credits,
subject name, and subject code.

19. Write Java programs to implementing Arithmetic exception and implementing Array
IndexOutOfBound exception.

20. Write a Java program that keeps a number from the user and generates an integer
between 1 and 12 and displays the name of the month.

Common questions

Powered by AI

Polymorphism allows objects of different classes to be treated as objects of a common super class or interface. In Java, an abstract class like Shape can provide a method getArea() that is overridden by specific shapes like Square or Cube, allowing these subclasses to have unique implementations while maintaining a common interface for using the method. Similarly, vehicles like TwoWheeler and FourWheeler can implement an interface Vehicle providing diverse implementations of shared methods .

Generics in Java enable the creation of classes and methods that operate on objects of various types, fostering code reuse and type safety. For example, a generic method can calculate the sum of any numeric type, like Integer, Double, etc., without altering the code for computing sums of specific data types, thus increasing the flexibility and maintainability of code .

Inheritance allows a base class, such as Employee, to define common methods and properties, such as getFirstName() and getLastName(), which can be extended by subclasses like ContractEmployee and RegularEmployee. These subclasses can then implement specific methods, for example, setDepartment() or setDesignation(), and define unique properties such as salary computation .

A custom exception can provide clearer, app-specific error messages that describe health-based eligibility more accurately than standard exceptions. For instance, a custom exception can specifically check for a positive COVID status and raise an alert if a student is ineligible to attend an exam due to health risks, making the application more intuitive and user-friendly .

Java can create a file-handling application that checks if a file exists and its attributes (readable, writable, type, length) by leveraging classes from the java.io package, such as File. Advanced exception handling mechanisms can improve user experience by catching potential FileNotFoundExceptions, providing user-friendly messages, and guiding users on corrective actions .

Threading in Java can be evaluated by developing a program that creates multiple threads to perform different tasks concurrently, such as generating random integers and computing properties based on conditions (e.g., odd or even). Running tasks in parallel can lead to improved performance but requires careful management to avoid conditions like race conditions or deadlocks. Ensure threads are correctly synchronized and managed to maintain accuracy .

Abstract classes like Vehicle can define general properties and behaviors, including methods like getConsumption() and displayConsumption(), which can be further specified by subclasses such as TwoWheeler and FourWheeler to include their own methods, maintenance() and average(). Interfaces like Vehicle can allow different implementations for methods like getColor() and getNumber(), facilitating a flexible design that accommodates diverse types without knowing each one's specifics .

A Java program managing subject data across packages, such as the 'dept' package with classes CSE, ECE, ME, and CE, may face challenges like proper access control (public, private) and package visibility. These can be tackled by using access modifiers to control access and dependencies between packages, and ensuring clear package structures and dependencies to manage visibility and communication among classes .

The Interface Segregation Principle suggests that clients should not be forced to depend on methods they do not use. In Java, this can be applied by using a Payable interface that includes just the getAmount() method, with classes like Invoice and Employee implementing this interface to provide their specific logic for calculating amounts. This avoids inserting unnecessary methods into the interface that would require unwanted implementation by certain classes, enhancing modularity and code maintainability .

Java allows the creation of user-defined exceptions, such as checking if a user is eligible to attend an exam based on health status. This can be implemented by defining a custom exception class and handling standard exceptions like NullPointerException and ArrayIndexOutOfBoundsException, enhancing robustness by allowing for more descriptive error messages and better user interaction .

You might also like