10-Hour Core Java Training Program
10-Hour Core Java Training Program
Session
2 Hours Fundamentals, Conditions and Loops 2 2 2
1
Session
2 Hours Arrays and Strings 2 2 2
2
Session
2 Hours OOP – Classes, Objects and Constructors 2 2 2
3
Session
2 Hours Exception Handling and Collections 2 2 2
5
Training Domain
Retail, Banking and Business Operations
1
EASY QUESTION 1 — CUSTOMER PURCHASE DISCOUNT
Real-World Scenario
A retail store provides a 10% discount when the customer's purchase amount is ₹5,000 or more.
Question
Write a Java program to accept the purchase amount and calculate the final payable amount after applying
the discount.
Solution
import [Link];
double discount = 0;
[Link]();
}
}
Explanation
The condition:
2
if (amount >= 5000)
Concepts Learned
Real-World Scenario
Question
Write a Java program to accept a shift code and display the corresponding employee shift.
Solution
import [Link];
switch (code) {
case 1:
[Link]("Morning Shift");
break;
case 2:
3
[Link]("Evening Shift");
break;
case 3:
[Link]("Night Shift");
break;
default:
[Link]("Invalid Shift Code");
}
[Link]();
}
}
Concepts Learned
Real-World Scenario
Question
Write a Java program to accept the number of electricity units consumed and calculate the total electricity
bill.
Solution
import [Link];
4
[Link]("Enter units consumed: ");
int units = [Link]();
double bill;
[Link]();
}
}
Example
Concepts Learned
Real-World Scenario
An ATM permits a withdrawal only when the amount is a multiple of ₹100 and sufficient balance is available.
5
Question
Accept the account balance and withdrawal amount. Validate the withdrawal and display the remaining
balance.
Solution
import [Link];
if (amount % 100 != 0) {
[Link](
"Amount must be a multiple of 100"
);
} else if (amount > balance) {
[Link]("Insufficient Balance");
} else {
balance = balance - amount;
[Link]("Withdrawal Successful");
[Link](
"Remaining Balance: Rs. " + balance
);
}
[Link]();
}
}
Concepts Learned
6
HARD QUESTION 1 — PARKING FEE CALCULATION
Real-World Scenario
Question
Write a Java program to calculate the parking fee based on the number of hours parked.
Solution
import [Link];
int fee;
if (hours <= 2) {
fee = hours * 30;
} else if (hours <= 5) {
fee = (2 * 30)
+ ((hours - 2) * 20);
} else {
fee = (2 * 30)
+ (3 * 20)
+ ((hours - 5) * 10);
}
7
[Link]("Parking Fee: Rs. " + fee);
[Link]();
}
}
Concepts Learned
Real-World Scenario
A retail manager records sales for seven days. The manager wants to calculate total sales, average sales,
highest daily sales and the number of days the ₹50,000 sales target was achieved.
Question
Write a Java program to accept sales for seven days and generate a weekly sales summary.
Solution
import [Link];
double total = 0;
double highest = 0;
int targetDays = 0;
8
if (sales >= 50000) {
targetDays++;
}
}
[Link]();
}
}
Concepts Learned
Training Domain
Student, Inventory and Customer Data Processing
Real-World Scenario
9
Question
Store five student marks in an array and calculate the average mark.
Solution
import [Link];
marks[i] = [Link]();
total += marks[i];
}
double average =
(double) total / [Link];
[Link]();
}
}
Concepts Learned
Real-World Scenario
10
Question
Accept a customer name and display the name in uppercase and the total number of characters.
Solution
import [Link];
[Link](
"Uppercase: " + [Link]()
);
[Link](
"Characters: " + [Link]()
);
[Link]();
}
}
Concepts Learned
Real-World Scenario
An inventory application stores product IDs. The inventory manager wants to check whether a product
exists.
Question
Store product IDs in an array and search for a product ID entered by the user.
11
Solution
import [Link];
int[] productIds = {
101, 105, 110, 125, 150
};
if (found) {
[Link]("Product Found");
} else {
[Link]("Product Not Found");
}
[Link]();
}
}
Concepts Learned
Real-World Scenario
A marketing company wants to identify the email service provider used by a customer.
12
Question
For example:
student@[Link]
Output:
[Link]
Solution
import [Link];
if (position != -1) {
String domain =
[Link](position + 1);
[Link]();
}
}
Concepts Learned
13
HARD QUESTION 1 — SECOND HIGHEST PRODUCT PRICE
Real-World Scenario
An e-commerce manager wants to find the second highest product price without sorting the complete list.
Question
Find the second highest value in an array of product prices without using sorting.
Solution
double highest =
Double.NEGATIVE_INFINITY;
double secondHighest =
Double.NEGATIVE_INFINITY;
[Link](
"Second Highest Price: Rs. "
+ secondHighest
);
}
}
14
Concepts Learned
Real-World Scenario
Question
Count the number of times the word good appears in a customer review. The comparison must be case-
insensitive.
Solution
import [Link];
String[] words =
[Link]().split("\\s+");
int count = 0;
[Link](
"'good' appears " + count + " times"
);
[Link]();
}
}
15
Concepts Learned
Training Domain
Banking, Product and Student Management
Real-World Scenario
Question
Create a BankAccount class containing account number, customer name and balance. Create an object
and display the account details.
Solution
class BankAccount {
int accountNumber;
String customerName;
double balance;
void displayAccount() {
[Link](
"Account Number: " + accountNumber
);
[Link](
"Customer Name: " + customerName
);
16
[Link](
"Balance: Rs. " + balance
);
}
}
[Link] = 1001;
[Link] = "Arun Kumar";
[Link] = 50000;
[Link]();
}
}
Concepts Learned
Real-World Scenario
Question
Create a Product class with product ID, product name and price. Use a parameterized constructor to
initialize the product.
Solution
class Product {
int productId;
String productName;
double price;
Product(
int productId,
String productName,
double price
) {
17
[Link] = productId;
[Link] = productName;
[Link] = price;
}
void displayProduct() {
[Link](
productId + " "
+ productName + " Rs. "
+ price
);
}
}
[Link]();
}
}
Concepts Learned
Real-World Scenario
Question
Create an Employee class with employee ID, name and monthly salary. Use a constructor and create a
method to calculate annual salary.
18
Solution
class Employee {
int employeeId;
String name;
double monthlySalary;
Employee(
int employeeId,
String name,
double monthlySalary
) {
[Link] = employeeId;
[Link] = name;
[Link] = monthlySalary;
}
double calculateAnnualSalary() {
return monthlySalary * 12;
}
void displayEmployee() {
[Link]("Employee: " + name);
[Link](
"Annual Salary: Rs. "
+ calculateAnnualSalary()
);
}
}
[Link]();
}
}
Concepts Learned
19
MEDIUM QUESTION 2 — PRODUCT CONSTRUCTOR OVERLOADING
Real-World Scenario
An inventory system may create a product with or without an initial stock quantity.
Question
Create a Product class with overloaded constructors. One constructor accepts product name and price.
Another accepts product name, price and stock quantity.
Solution
class Product {
String name;
double price;
int stock;
Product(
String name,
double price,
int stock
) {
[Link] = name;
[Link] = price;
[Link] = stock;
}
void display() {
[Link](
name + " Rs. "
+ price + " Stock: "
+ stock
);
}
}
20
Product product1 =
new Product("Laptop", 75000);
Product product2 =
new Product(
"Mobile",
50000,
25
);
[Link]();
[Link]();
}
}
Concepts Learned
Constructor overloading.
Real-World Scenario
A bank wants each account object to maintain its own balance and perform deposit and withdrawal
operations.
Question
Create a BankAccount class with a constructor. Implement deposit, withdrawal and balance display
methods. Reject withdrawals when the balance is insufficient.
Solution
class BankAccount {
int accountNumber;
String customerName;
double balance;
BankAccount(
int accountNumber,
String customerName,
double balance
) {
[Link] = accountNumber;
[Link] = customerName;
21
[Link] = balance;
}
void displayBalance() {
[Link](
customerName
+ " Balance: Rs. "
+ balance
);
}
}
[Link](10000);
[Link](25000);
[Link]();
}
}
22
Concepts Learned
Real-World Scenario
A college stores student records as objects and wants to identify the highest-scoring student.
Question
Create a Student class with USN, student name and marks. Store five Student objects in an array and
display the student having the highest marks.
Solution
class Student {
String usn;
String name;
int marks;
Student(
String usn,
String name,
int marks
) {
[Link] = usn;
[Link] = name;
[Link] = marks;
}
void display() {
[Link](
usn + " "
+ name + " "
+ marks
);
}
}
23
"1HK24CS001",
"Arun",
82
),
new Student(
"1HK24CS002",
"Ayesha",
91
),
new Student(
"1HK24CS003",
"Sneha",
87
),
new Student(
"1HK24CS004",
"Rahul",
76
),
new Student(
"1HK24CS005",
"Imran",
89
)
};
[Link](
"Highest Scoring Student"
);
[Link]();
}
}
Concepts Learned
24
SESSION 4 — OOP: INHERITANCE, METHOD
OVERRIDING AND POLYMORPHISM
Topics Covered
Inheritance, extends, super, method overriding, parent reference, child object, runtime polymorphism and
abstract classes.
Training Domain
Employee, Payment and Service Management
Real-World Scenario
A company maintains general employee details and additional salary details for permanent employees.
Question
Create an Employee parent class and a PermanentEmployee child class. Display employee name and
salary.
Solution
class Employee {
String name;
Employee(String name) {
[Link] = name;
}
}
PermanentEmployee(
String name,
double salary
) {
super(name);
[Link] = salary;
25
}
void display() {
[Link]("Name: " + name);
[Link](
"Salary: Rs. " + salary
);
}
}
[Link]();
}
}
Concepts Learned
Real-World Scenario
Question
Create a Payment class and override the processPayment() method in a UPIPayment class.
Solution
class Payment {
void processPayment() {
[Link](
"Processing General Payment"
);
}
}
26
class UPIPayment extends Payment {
@Override
void processPayment() {
[Link](
"Processing UPI Payment"
);
}
}
[Link]();
}
}
Concepts Learned
Method overriding.
Real-World Scenario
Question
Create an Employee parent class and PermanentEmployee child class. Calculate the final salary.
Solution
class Employee {
String name;
double basicSalary;
Employee(
String name,
double basicSalary
) {
[Link] = name;
[Link] = basicSalary;
27
}
}
PermanentEmployee(
String name,
double basicSalary
) {
super(name, basicSalary);
}
double calculateSalary() {
return basicSalary
+ basicSalary * 0.20;
}
}
[Link](
"Final Salary: Rs. "
+ [Link]()
);
}
}
Concepts Learned
Real-World Scenario
28
Question
Solution
class Payment {
void processPayment() {
[Link](
"Processing Payment"
);
}
}
29
Concepts Learned
Real-World Scenario
Question
Design a payroll system using inheritance, method overriding and runtime polymorphism.
Solution
class Employee {
String name;
double basicSalary;
Employee(
String name,
double basicSalary
) {
[Link] = name;
[Link] = basicSalary;
}
double calculateSalary() {
return basicSalary;
}
}
PermanentEmployee(
String name,
double basicSalary
) {
super(name, basicSalary);
}
@Override
double calculateSalary() {
return basicSalary
30
+ basicSalary * 0.20;
}
}
ContractEmployee(
String name,
double basicSalary
) {
super(name, basicSalary);
}
@Override
double calculateSalary() {
return basicSalary
+ basicSalary * 0.05;
}
}
Concepts Learned
31
HARD QUESTION 2 — DELIVERY CHARGE POLYMORPHISM
Real-World Scenario
Question
Design a delivery charge calculation system using an abstract class and runtime polymorphism.
Solution
void displayCharge() {
[Link](
"Delivery Charge: Rs. "
+ calculateCharge()
);
}
}
32
public class DeliverySystem {
public static void main(String[] args) {
Delivery[] deliveries = {
new StandardDelivery(),
new ExpressDelivery(),
new SameDayDelivery()
};
Concepts Learned
Training Domain
Banking, Student and Inventory Applications
Real-World Scenario
A restaurant divides the bill equally among customers. The application must handle a customer count of
zero.
Question
Accept the total bill and number of customers. Handle division by zero.
33
Solution
import [Link];
try {
[Link]("Enter bill: ");
int bill = [Link]();
[Link](
"Enter number of customers: "
);
[Link](
"Amount per Customer: Rs. "
+ amount
);
} catch (ArithmeticException e) {
[Link](
"Customer count cannot be zero"
);
}
[Link]();
}
}
Concepts Learned
Real-World Scenario
34
Question
Solution
import [Link];
[Link]("Arun");
[Link]("Ayesha");
[Link]("Sneha");
Concepts Learned
Real-World Scenario
A banking application must reject withdrawal amounts greater than the account balance.
Question
Use throw to generate an exception when the withdrawal amount exceeds the available balance.
Solution
35
try {
if (withdrawal > balance) {
throw new IllegalArgumentException(
"Insufficient Balance"
);
}
balance -= withdrawal;
[Link](
"Balance: Rs. " + balance
);
} catch (IllegalArgumentException e) {
[Link]([Link]());
}
}
}
Concepts Learned
Real-World Scenario
Question
Use a HashMap to store product ID and price. Search for a product ID and display its price.
Solution
import [Link];
[Link](101, 45000.0);
[Link](102, 75000.0);
[Link](103, 32000.0);
36
int searchId = 102;
if ([Link](searchId)) {
[Link](
"Price: Rs. "
+ [Link](searchId)
);
} else {
[Link](
"Product Not Found"
);
}
}
}
Concepts Learned
Real-World Scenario
Question
Solution
class InsufficientBalanceException
extends Exception {
InsufficientBalanceException(
String message
) {
super(message);
}
}
class Account {
private double balance;
37
Account(double balance) {
[Link] = balance;
}
balance -= amount;
[Link](
"Remaining Balance: Rs. "
+ balance
);
}
}
try {
[Link](70000);
} catch (
InsufficientBalanceException e
) {
[Link]([Link]());
}
}
}
Concepts Learned
38
HARD QUESTION 2 — STUDENT PERFORMANCE MANAGEMENT
Real-World Scenario
A college wants to dynamically maintain student records and identify students who scored 75 or above.
Question
Create a Student class. Store Student objects in an ArrayList and display students having marks greater than
or equal to 75.
Solution
import [Link];
class Student {
String usn;
String name;
int marks;
Student(
String usn,
String name,
int marks
) {
[Link] = usn;
[Link] = name;
[Link] = marks;
}
}
[Link](
new Student(
"1HK24CS001",
"Arun",
82
)
);
[Link](
new Student(
39
"1HK24CS002",
"Ayesha",
68
)
);
[Link](
new Student(
"1HK24CS003",
"Sneha",
91
)
);
Concepts Learned
Session Fundamentals, Conditions and Variables, Scanner, if, switch, loops and
2 Hours
1 Loops business logic
Session OOP – Classes, Objects and Classes, objects, constructors, this and
2 Hours
3 Constructors arrays of objects
40
Session Duration Topic Key Skills
TRAINING OUTCOME
At the end of the 10-hour Core Java training, students will be able to solve real-world computational
problems using Java fundamentals, process structured and textual data using arrays and strings, model
real-world entities using classes and objects, initialize and manage object state using constructors, design
reusable object-oriented systems using inheritance, method overriding and polymorphism, handle
application failures using Java exception handling, and manage dynamic application data using the Java
Collections Framework.
The training includes 30 real-world programming problems: 10 Easy, 10 Medium and 10 Hard problems,
progressing systematically from fundamental programming to object-oriented application development.
41