Winsem2024-25 Bcse103e Ela VL2024250505256 Model-Question-Paper
Winsem2024-25 Bcse103e Ela VL2024250505256 Model-Question-Paper
1. Write a Java Program to test the logical operators. Use short-circuit evaluation?.
Imagine you're building a login system where you validate user credentials. Use short-
circuiting ( and && ) plays a crucial role.
2. Write a Java Program to test the logical operators. Use short-circuit evaluation?.
Imagine you're building a login system where you validate user credentials. Use short-
circuiting ( and || ) plays a crucial role.
3. Given a set of rules for student eligibility (minimum attendance of 75% and a passing
grade of at least 50%), write a Java program that checks whether a student qualifies
using logical operators
4. Bitwise operators can be useful for managing permissions in systems where multiple
flags are combined efficiently. Read (0001 → 1), Write(0010 → 2) Execute (0100→4),
Delete ((1000 → 8). Use scanner to get the User name (String) and their permission
level (4 bit binary value by addition of all 1111). Display the User name and Permission
type. Ask a question to revoke and disable any permission. After the execution, display
the status.
5. Bitwise operators can be useful for managing permissions in systems where multiple
flags are combined efficiently. View Account (0001 → 1), Withdraw Funds(0010 → 2)
Transfer Funds (0100→4), Close Account ((1000 → 8). Use scanner to get the User
name (String) and their permission level (4 bit binary value by addition of all 1111).
Display the User name and Permission type. Ask a question to revoke and disable any
permission. After the execution, display the status.
6. Relational operators in Java (==, !=, >, <, >=, <=) help in comparing values and making
decisions. Write a Java program for a student grade evaluation system where relational
operators determine pass/fail status and grade classification
7. Instead of student grading, let’s create an employee performance evaluation system that
categorizes employees based on their annual performance score using relational
operators. Performance Classification Rules (Outstanding: Score >= 90, Exceeds
Expectations: Score >= 75 and < 90, Meets Expectations: Score >= 50 and < 75, Needs
Improvement: Score < 50) The program will take employee name and score, evaluate
their performance category, and determine whether they qualify for a bonus.
8. Imagine you are building a simple employee database where users can search for an
employee ID from an array of employee records. The program will: store employee
IDs in an array, allow the user to search for an ID, if found display the result.
9. Developing an e-commerce platform, where product prices need to be sorted to help
customers view items in ascending order (lowest to highest) or descending order
(highest to lowest). Sorting ensures better price comparisons and enhances user
experience. Write a java program which sorts the price based on the user input
ascending or descending order which is stored in an array.
10. Calculate students’ average scores, highest score, lowest score using array passing to
methods. User inputs the number of students and creates an array dynamically. Enter
the scores. Call for a method which processes the array like average scores, highest
score, lowest score and display the value
11. Designing an employee attendance tracking system where each row in a 2D array
represents an employee, and each column represents their attendance for a particular
week. The program will: store attendance records in a 2D array (1 for Present, 0 for
Absent), pass the 2D array to methods to calculate, Total attendance per employee.
Display the attendance status for each employee
12. A jagged array is useful when different groups of data have varying lengths. For
example, in a university system, students may take different numbers of exams
depending on their subject choices. Write a java program which handles jagged array
for student scores.
13. A Business sales tracking system, where sales data for different departments is recorded
for each month. Rows representing departments, columns representing monthly sales
figures. Using an enhanced for loop to the 2d array, display each department’s sales,
calculate the total sales for each department and overall company sales.
14. The program takes a 5x5 input and outputs the same in a transposed matrix. Write a
Java program which takes the 5x5 input, the value varies between 0 -255 for each input
and transposed output is displayed.
15. An anagram is a word or a phrase made by transposing the letters of another word or
phrase; for example, "parliament" is an anagram of "partial men," and "software" is an
anagram of "swear oft." Write a program that figures out whether one string is an
anagram of another string. The program should ignore white space and punctuation.
16. Write a Java program that takes a number as input and prints its equivalent as
Binary, Hexadecimal, Octal number based on the CASE input through the scanner
statement.
17. Write a Java program which receives an encryption key to shift the alphabets value in
a Caesar cipher and the plain text message is encrypted and vice versa in decryption
process of an encrypted message back to the given plaintext message?
18. Write a Java program which receives a series of String inputs which is stored in a string
array. The program should receive a character input from the user to find and replace
the substring (Character replace ar with xy Chxyacter) with another character in the
String array.
Part B
3. Abstract Superclass Shape and Its Concrete Subclasses. The superclass Shape
and its subclasses Circle, Rectangle and Square are as follows. Shape is an
abstract class containing 2 abstract methods: getArea() and getPerimeter(), where
its concrete subclasses must provide its implementation. All instance variables
shall have protected access, i.e., accessible by its subclasses and classes in the
same package. Mark all the overridden methods with annotation @Override.
4. Abstract Superclass Shape and Its Concrete Subclasses. How would you design
the vehicle superclass and ensure its subclasses (car, bike, and truck ) implement
getMaxSpeed() and getFuelEfficiency(). All instance variables shall have
protected access, i.e., accessible by its subclasses and classes in the same
package. Mark all the overridden methods with annotation @Override.
Data Members
(a) Name of the depositor,
(b) account number,
(c) Type of account
(d) Balance amount in the account
Methods
To assign initial values
To deposit an amount
To withdraw an amount after checking the balance
To display the name and balance
Write a java program to write the following into the text file in the following format.
@12% for food items
@18% non food items
Bill.txt
Grocery Bill No. :2025-03-001
Customer Name : R. Sivacoumar
Customer Phone : 9952840844
___________________________________________________________________________
_____
Sl. No. Item Name Quantity Purchased Unit Value Total Amount
GST
___________________________________________________________________________
_____
1 Onion kg 4 25.00 100.00
12.00
2 Atta kg 2 49.00 98.00
11.76
3 Sunflower oil L 2 123.50
4 Jam Mixed nos 1 185.00
5 Detergent kg 1.5 1450.00
___________________________________________________________________________
_____
Total 221.76 (including GST)
___________________________________________________________________________
_____
7. Write a java program to search for an item in csv file and include in a bill.
Bill.txt should be like the below. You can manually create a CSV file with the item
list and unit price only. In the main program, input the Item Code, Purchase
Quantity,
___________________________________________________________________________
_____
Total 221.76 (including GST)
___________________________________________________________________________
_____
8. A person is investing in LIC Rs.5000 every year. Write a Java program to calculate the
total returns (a) If he has paid the full term of 20 years and acquired bonus at a rate of
10 % after every 5 years. The accumulated sum after every year is 1.5 % compound
interest for first years and increase of 2 % after 5 years thereafter. Calculate the total
assured sum after 20 years
9. A person deposits ₹10,000 per year into a fixed deposit scheme with a compound
interest rate of 5% annually. The scheme includes: Bonus: A loyalty bonus of
₹2,000 every 4 years. Penalty: If the person withdraws before 15 years, a 2%
annual penalty is deducted. Write a Java program that calculates the total amount
accumulated for a full 15-year deposit term. A case where the deposit is stopped
after 10 years and penalties apply. Output should be stored in a csv format table.
10. Write a Java program which uses Classes, Object, passing objects to methods.
Convert the given cartesian (5,4,2) to spherical co-ordinates (ρ = √(x2 + y2 + z2)
θ = tan-1(y/x), φ = cos-1(z/√(x2 + y2 + z2)), Write the output to a txt file named
spherical.txt
19. Write a Java Program to test the logical operators. Use short-circuit evaluation?.
Imagine you're building a login system where you validate user credentials. Use short-
circuiting ( and && ) plays a crucial role.
package sample1;
import java.util.Scanner;
public class ShortCircuitLogin {
public static void main(String[] args) {
String correctUsername = "admin";
String correctPassword = "secure123";
Scanner scanner = new Scanner(System.in);
System.out.print("Enter username: ");
String inputUsername = scanner.nextLine();
System.out.print("Enter password: ");
String inputPassword = scanner.nextLine();
// Short-circuiting prevents password check if username is incorrect
if (inputUsername.equals(correctUsername) &&
inputPassword.equals(correctPassword)) {
System.out.println("Login successful!");
} else {
package sample1;
import java.util.Scanner;
public class ShortCircuitLogin {
public static void main(String[] args) {
String correctUsername = "admin";
String correctPassword = "secure123";
Scanner scanner = new Scanner(System.in);
System.out.print("Enter username: ");
String inputUsername = scanner.nextLine();
System.out.print("Enter password: ");
String inputPassword = scanner.nextLine();
// Short-circuiting prevents password check if username is incorrect
if (inputUsername.equals("admin") || inputPassword.equals("override123")) {
System.out.println("Admin access granted!");
}else {
import java.util.Scanner;
// Display result
if (isEligible) {
System.out.println("Student qualifies for eligibility.");
} else {
System.out.println("Student does NOT qualify.");
if (attendance < 75) {
System.out.println("Reason: Insufficient attendance.");
}
if (grade < 50) {
System.out.println("Reason: Low grade.");
}
}
scanner.close();
}
}
22. Bitwise operators can be useful for managing permissions in systems where multiple
flags are combined efficiently. Read (0001 → 1), Write(0010 → 2) Execute (0100→4),
Delete ((1000 → 8). Use scanner to get the User name (String) and their permission
level (4 bit binary value by addition of all 1111). Display the User name and Permission
type. Ask a question to revoke and disable any permission. After the execution, display
the status.
package sample1;
import java.util.Scanner;
scanner.close();
}
23. Bitwise operators can be useful for managing permissions in systems where multiple
flags are combined efficiently. View Account (0001 → 1), Withdraw Funds(0010 → 2)
Transfer Funds (0100→4), CloseAccount ((1000 → 8). Use scanner to get the User
name (String) and their permission level (4 bit binary value by addition of all 1111).
Display the User name and Permission type. Ask a question to revoke and disable any
permission. After the execution, display the status.
package sample1;
import java.util.Scanner;
scanner.close();
}
// Method to display active access rights
public static void displayAccessRights(int accessLevel) {
System.out.println("View Account: " + ((accessLevel & VIEW_ACCOUNT) !=
0 ? "Allowed" : " Not Allowed"));
System.out.println("Withdraw Funds: " + ((accessLevel &
WITHDRAW_FUNDS) != 0 ? "Allowed" : " Not Allowed"));
System.out.println("Transfer Money: " + ((accessLevel &
TRANSFER_MONEY) != 0 ? " Allowed" : " Not Allowed"));
System.out.println("Close Account: " + ((accessLevel & CLOSE_ACCOUNT)
!= 0 ? " Allowed" : " Not Allowed"));
}
}
5. Relational operators in Java (==, !=, >, <, >=, <=) help in comparing values and making
decisions. Write a Java program for a student grade evaluation system where relational
operators determine pass/fail status and grade classification
package sample1;
import java.util.Scanner;
// Display results
System.out.println("\nStudent: " + studentName);
System.out.println("Score: " + score);
System.out.println("Pass Status: " + (isPassed ? "✅ Passed" : "❌ Failed"));
scanner.close();
}
}
6. Instead of student grading, let’s create an employee performance evaluation system that
categorizes employees based on their annual performance score using relational
operators. Performance Classification Rules (Outstanding: Score >= 90, Exceeds
Expectations: Score >= 75 and < 90, Meets Expectations: Score >= 50 and < 75, Needs
Improvement: Score < 50) The program will take employee name and score, evaluate
their performance category, and determine whether they qualify for a bonus.
package sample1;
import java.util.Scanner;
// Relational checks
boolean isOutstanding = score >= 90;
boolean exceedsExpectations = score >= 75 && score < 90;
boolean meetsExpectations = score >= 50 && score < 75;
boolean needsImprovement = score < 50;
boolean qualifiesForBonus = score >= 75; // Employees with 75+ score get a
bonus
// Display results
System.out.println("\nEmployee: " + employeeName);
System.out.println("Performance Score: " + score);
if (isOutstanding) {
System.out.println("Rating: 🌟 Outstanding");
} else if (exceedsExpectations) {
System.out.println("Rating: 👍 Exceeds Expectations");
} else if (meetsExpectations) {
System.out.println("Rating: ✅ Meets Expectations");
} else {
System.out.println("Rating: ❌ Needs Improvement");
}
scanner.close();
}
}
7. Imagine you are building a simple employee database where users can search for an
employee ID from an array of employee records. The program will: store employee
IDs in an array, allow the user to search for an ID, if found display the result.
package sample1;
import java.util.Scanner;
public class EmployeeSearch {
public static void main(String[] args) {
// Example employee ID database
int[] employeeIDs = {101, 203, 305, 408, 512};
package sample1;
import java.util.Arrays;
import java.util.Scanner;
scanner.close();
}
// Method to reverse array for descending order
public static void reverseArray(double[] arr) {
int n = arr.length;
for (int i = 0; i < n / 2; i++) {
double temp = arr[i];
arr[i] = arr[n - i - 1];
arr[n - i - 1] = temp;
}
}
}
9. Calculate students’ average scores, highest score, lowest score using array passing to
methods. User inputs the number of students and creates an array dynamically. Enter
the scores. Call for a method which processes the array like average scores, highest
score, lowest score and display the value
package sample1;
import java.util.Scanner;
// Input scores
System.out.println("Enter the scores:");
for (int i = 0; i < n; i++) {
System.out.print("Student " + (i + 1) + ": ");
scores[i] = scanner.nextDouble();
}
System.out.println("\nResults:");
System.out.println("Average Score: " + averageScore);
System.out.println("Highest Score: " + highestScore);
System.out.println("Lowest Score: " + lowestScore);
scanner.close();
}
10. Calculate students’ average scores, highest score, lowest score using array passing to
methods. User inputs the number of students and creates an array dynamically. Enter
the scores. Call for a method which processes the array like average scores, highest
score, lowest score and display the value
package sample1;
import java.util.Scanner;
// Input scores
System.out.println("Enter the scores:");
for (int i = 0; i < n; i++) {
System.out.print("Student " + (i + 1) + ": ");
scores[i] = scanner.nextDouble();
}
System.out.println("\nResults:");
System.out.println("Average Score: " + averageScore);
System.out.println("Highest Score: " + highestScore);
System.out.println("Lowest Score: " + lowestScore);
scanner.close();
}
11. Designing an employee attendance tracking system where each row in a 2D array
represents an employee, and each column represents their attendance for a particular
week. The program will: store attendance records in a 2D array (1 for Present, 0 for
Absent), pass the 2D array to methods to calculate, Total attendance per employee.
Display the attendance status for each employee
package sample1;
import java.util.Scanner;
scanner.close();
}
12. A jagged array is useful when different groups of data have varying lengths. For
example, in a university system, students may take different numbers of exams
depending on their subject choices. Write a java program which handles jagged array
for student scores.
package sample1;
import java.util.Scanner;
scanner.close();
}
}
13. A Business sales tracking system, where sales data for different departments is recorded
for each month. Rows representing departments, columns representing monthly sales
figures. Using an enhanced for loop to the 2d array, display each department’s sales,
calculate the total sales for each department and overall company sales.
package sample1;
public class SalesReport{
public static void main(String[] args) {
// Define department names
String[] departments = {"Electronics", "Clothing", "Groceries"};
// Create matrix
int[][] matrix = new int[rows][cols];
// Compute transpose
int[][] transposed = new int[cols][rows]; // Swap row and column sizes
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
transposed[j][i] = matrix[i][j]; // Transposing
}
}
scanner.close();
}
}
1. A class called circle is designed as following. It contains: Two private instance
variables: radius (of the type double) and color (of the type String), with default
value of 1.0 and "red", respectively. Two overloaded constructors - a default
constructor with no argument, and a constructor which takes a double argument
for radius and color. Two public methods: getRadius() and getArea(), which return
the radius and area of this instance, respectively.
package sample1;
public class Circle {
// Private instance variables
private double radius;
private String color;
package sample1;
public class Rectangle {
// Private instance variables
private double length;
private double width;
private String color;
3. Abstract Superclass Shape and Its Concrete Subclasses. The superclass Shape
and its subclasses Circle, Rectangle and Square are as follows. Shape is an
abstract class containing 2 abstract methods: getArea() and getPerimeter(), where
its concrete subclasses must provide its implementation. All instance variables
shall have protected access, i.e., accessible by its subclasses and classes in the
same package. Mark all the overridden methods with annotation @Override.
package sample1;
// Abstract superclass Shape
abstract class Shape {
protected String color; // Protected instance variable
// Constructor
public Circle(double radius, String color) {
super(color);
this.radius = radius;
}
// Constructor
public Rectangle(double length, double width, String color) {
super(color);
this.length = length;
this.width = width;
}
// Displaying results
System.out.println("Circle - Color: " + circle.getColor() + ", Area: " +
circle.getArea() + ", Perimeter: " + circle.getPerimeter());
System.out.println("Rectangle - Color: " + rectangle.getColor() + ", Area: " +
rectangle.getArea() + ", Perimeter: " + rectangle.getPerimeter());
System.out.println("Square - Color: " + square.getColor() + ", Area: " +
square.getArea() + ", Perimeter: " + square.getPerimeter());
}
}
Key Features
Abstract Class () →(Shape Contains → getArea() and getPerimeter() abstract
methods.
Protected Variables → Allows access within subclasses.
Overridden Methods () → Concrete subclasses implement and .
Square Extends Rectangle → A square is a special case of a rectangle.
4. Abstract Superclass Shape and Its Concrete Subclasses. How would you design
the vehicle superclass and ensure its subclasses (car, bike, and truck ) implement
getMaxSpeed() and getFuelEfficiency() properly? All instance variables shall have
protected access, i.e., accessible by its subclasses and classes in the same
package. Mark all the overridden methods with annotation @Override.
// Constructor
public Vehicle(int speed, double fuelEfficiency) {
this.speed = speed;
this.fuelEfficiency = fuelEfficiency;
}
// Implement getMaxSpeed()
@Override
public int getMaxSpeed() {
return speed;
}
// Implement getFuelEfficiency()
@Override
public double getFuelEfficiency() {
return fuelEfficiency;
}
}
// Implement getMaxSpeed()
@Override
public int getMaxSpeed() {
return speed;
}
// Implement getFuelEfficiency()
@Override
public double getFuelEfficiency() {
return fuelEfficiency;
}
}
// Implement getMaxSpeed()
@Override
public int getMaxSpeed() {
return speed;
}
// Implement getFuelEfficiency()
@Override
public double getFuelEfficiency() {
return fuelEfficiency;
}
}
// Displaying results
System.out.println("Car - Max Speed: " + car.getMaxSpeed() + " km/h, Fuel
Efficiency: " + car.getFuelEfficiency() + " km/l");
System.out.println("Bike - Max Speed: " + bike.getMaxSpeed() + " km/h, Fuel
Efficiency: " + bike.getFuelEfficiency() + " km/l");
System.out.println("Truck - Max Speed: " + truck.getMaxSpeed() + " km/h, Fuel
Efficiency: " + truck.getFuelEfficiency() + " km/l");
}
}