Go to the profile of  Paras Patidar
Paras Patidar
I am working on Machine Learning, Python and Django.
3 min read
List of Scenario-Based Java Programs

List of Scenario-Based Java Programs

Java is a general-purpose programming language that is class-based, object-oriented, and designed to have as few implementation dependencies as possible.

Here are the list of Java Programs. Just click on the below and download the pdf..

Want the solution of the question please comment in the comment section.

Top Java Programs

Learning Computer Programming Using Java with 101 Examples

Scenario Based Questions

1. Write a program to create a class Voter which contains attributes name, date_of_birth and voter_id and voter has a Voter_Card. Provide appropriate constructor to initialize all the attributes of the Voter but voter id must be assigned automatically only when the age of the voter is greater than or equal to 18 years.VoterCard is a nested class with attributes voter_id and Voter_name. Make sure that voter card is created only when user is a valid voter and if it is already created then must not be assigned the new voter id.

2.  Write a program to create a class Employee with appropriate fields for employee name, employee id and Vehicle.Vehicle is a nested class with attributes vehicle number and owner name. An employee may or may not have a vehicle.Create at least 3 employee objects using appropriate constructor and store the employee objects in a collection.Implement a method getVehicleDetails(String Vehicle_number) to display the name and id of the employee who own that vehicle.

3. Write a program to define an interface Testing which contains an abstract methodboolean checkString(String str)Create a class Input which must contain a method String getInput(Testing obj) which prompts the user to enter a String and the String must be checked using the checkString such that it returns TRUE only when the String contains all the vowels. If input is correct then display “String Accepted” otherwise ask to re-enter the String.

4. Create a functional interface Predicate with an abstract method test with following signature:boolean test(String t);Write a test program to check a string contains character 'c' or not by using above test method with the help of lambda expression.

5. Write a program to define a class named Demo which contains a local class named MyLocal inside its constructor. Define a method sayHello (String XXX) to display Hello XXX (e.g Hello Ravi if name is Ravi).Define a class named TestLocal which reads the name from the user and then invoke the sayHello method of MyLocal class.  

6. Create a class Laptop with attributes model_number, price and RAM.In main class prompt the user to filter on the basis of model, price or RAM and if user selects Price then display all the laptops in descending order of the price and if user selects RAM then display all the laptops in ascending order of their RAM and if user select model then ask to enter the keyword for model and display all the laptops which contain that keyword in model_number.

7. Write a program to define two interfaces UGC and AICTE both having a default methodint getAdmission() to take the admission and an abstract method String payFee().getAdmission() in UGC must ask the percentage in qualifying exam and if the percentage >= 60 then generate the registration number and return.getAdmission() is AICTE must ask the user to join the counseling after 5 days and displaythe date of counseling and return the counseling token number.Create a class University which inherits both UGC and AICTE and overrides the getAdmission() method only such that it will ask the percentage and if direct admission through UGC is possible then proceed otherwise proceed through AICTE.University must have attribute fee_due and it should be assigned the due amount accordingly.(E.g fee through UGC is 25000 & fee through AICTE is 34000)Create a class LPU which inherits University and overrides all the methods. Ask the user to deposit the fee and display the fee due. After depositing the fee display the remaining due fee and return the receipt number.

Top 30 Java Tutorials and Resources