Q1
class Number {
int num;
Number(int n) {
num = n;
void Reverse() {
int rev = 0, temp = num;
while (temp != 0) {
int digit = temp % 10;
rev = rev * 10 + digit;
temp /= 10;
[Link]("Original Number: " + num);
[Link]("Reversed Number: " + rev);
public static void main(String[] args) {
Number n = new Number(34521);
[Link]();
}
Q2
class Largest {
void findLargest(int a, int b, int c) {
int max;
if (a >= b && a >= c)
max = a;
else if (b >= a && b >= c)
max = b;
else
max = c;
[Link]("Largest Number is: " + max);
public static void main(String[] args) {
Largest obj = new Largest();
[Link](25, 87, 64);
Q3
class Student {
String name;
int rollNo;
double fees;
Student(String n, int r, double f) {
name = n;
rollNo = r;
fees = f;
void display() {
[Link]("Name: " + name);
[Link]("Roll No: " + rollNo);
[Link]("Fees: " + fees);
[Link]("---------------------");
public static void main(String[] args) {
Student s1 = new Student("Rahul", 101, 25000);
Student s2 = new Student("Priya", 102, 30000);
[Link]();
[Link]();
}
Q4
class Account {
String name, accType;
int accNo;
double balance;
Account(String n, String type, int no, double bal) {
name = n;
accType = type;
accNo = no;
balance = bal;
void deposit(double amount) {
balance += amount;
[Link]("Amount Deposited: " + amount);
[Link]("Updated Balance: " + balance);
void balance() {
[Link]("Current Balance: " + balance);
void interest(double rate, int years) {
if ([Link]("Saving")) {
double ci = balance * [Link]((1 + rate / 100), years) - balance;
[Link]("Compound Interest for " + years + " years: " + ci);
} else {
[Link]("Current Account: No Interest Applicable");
void withdraw(double amount) {
if (balance - amount < 0) {
[Link]("Insufficient Balance!");
} else {
balance -= amount;
[Link]("Amount Withdrawn: " + amount);
[Link]("Remaining Balance: " + balance);
// Check for Current account limit
if ([Link]("Current") && balance < 5000) {
[Link]("Balance below 5000! Service charges applied.");
balance -= 200; // example service charge
[Link]("After Service Charge Balance: " + balance);
public static void main(String[] args) {
Account saving = new Account("Amit", "Saving", 1001, 10000);
Account current = new Account("Rohit", "Current", 1002, 6000);
[Link]("\n--- Saving Account ---");
[Link](2000);
[Link](5, 2);
[Link](3000);
[Link]();
[Link]("\n--- Current Account ---");
[Link](1000);
[Link](2500);
[Link]();