0% found this document useful (0 votes)
12 views11 pages

Question Bank

Uploaded by

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

Question Bank

Uploaded by

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

Write a java program to enter the marks obtained in five subjects: Physics,

Chemistry, Biology, Mathematics, and Computer. Calculate the overall percentage


and assign a grade based on the following criteria:
● Percentage >= 90% : Grade A
● Percentage >= 80% : Grade B
● Percentage >= 70% : Grade C
● Percentage >= 60% : Grade D
● Percentage >= 40% : Grade E
● Percentage < 40% : Grade F
The program should output the calculated percentage and the corresponding grade.

Design and implement a Java program to apply text processing techniques using
Java strings. Your program should:

1. Read user input (string)


2. Implement string manipulation methods:
- Reverse string
- Convert to uppercase/lowercase
- Remove duplicates
- Count vowels/consonants

Design and implement a Java program to apply array searching and indexing
techniques.
1. Create an array to store a given number of elements input by the user
2. Write a method to search for elements from another input array (search array)
within the created array
3. Find and store the positions of all search array elements within the created array
4. Print out all search array elements with their corresponding positions (Level 3:
Apply).
Create a class named Distance with two member variables: feet and inches. Include
the following:
1. A default constructor that initializes both feet and inches to zero.
2. A parameterized constructor that initializes feet and inches to specific values.
3. A method to display the distance in feet and inches format.
4. A method that takes another Distance object as an argument, adds the values
of the two distances, and returns the result as a new Distance object.
In the main method:
● Create two Distance objects with specific initial values, and a
third Distance object without initial values.
● Add the values of the two initialized objects and store the result in the third
object.
● Finally, display the values of all three distance objects.

Design and implement a menu-driven Java application to maintain student


information.
(Use Java classes and objects)

1. Create a `Student` class with attributes:


- `name`
- `registerNo`
- `department`
- `specialization`
- `cgpa`
- `hostelName`
- `mentorName`
- `noOfArrears`

2. Implement constructors, getter, and setter methods for the `Student` class.

3. Develop a menu-driven application with the following options:


- Add Student Details
- Edit Student Details
- Delete Student Details
- Display Student Details
- Exit
Develop a Java application using inheritance to create a simple program for
calculating the area of different shapes.
1. Define a Base Class (Shape):
o Create a class called Shape with two double type data members for
dimensions that will be used to calculate the area.
o Include setter and getter methods to initialize these dimensions.
o Add a method findArea() in the Shape class to calculate and display
the area.
2. Derive Subclasses:
o Create two subclasses, Triangle and Rectangle, that inherit
from Shape.
o Override the findArea() method in each subclass to calculate and
display the area specific to each shape:
▪ For Triangle: Area = 0.5 * base * height

▪ For Rectangle: Area = length * width


3. Implement Polymorphism:
o Use runtime polymorphism to call the appropriate findArea() method
based on the object type.
o Provide a menu-driven option that allows the user to select a shape
(either Triangle or Rectangle), enter the required dimensions, and view
the calculated area.
Ensure your program demonstrates inheritance and runtime polymorphism.
Develop a Java application that simulates an ATM machine using inheritance.
1. Define a Base Class (CashTree):
o Create a superclass named CashTree to represent an ATM.
o Include common attributes such as name, codeNo, and location.
o Implement basic functionalities in the superclass, such
as viewBalance, withdraw, and deposit.
2. Create Bank-Specific Subclasses:
o Derive two subclasses, SBI_Bank and HDFC_Bank, that inherit
from CashTree.
o Add specific attributes for each subclass, such
as customerName and balance.
o Override the functionalities from CashTree in each subclass to reflect
differences based on the bank's policies, including:
▪ Service charges

▪ Interest rates
▪ Maximum withdrawal limits
3. Implement Polymorphism:
o Use runtime polymorphism to customize the behavior
of viewBalance, withdraw, and deposit based on the bank (SBI or
HDFC).
o Create a menu-driven program that allows users to:
▪ Choose a bank

▪ Perform ATM operations (check balance, withdraw, deposit)


▪ View any specific terms related to service charges or limits for
the selected bank
Ensure the program demonstrates inheritance, polymorphism, and a user-friendly
interface with menu options.
Develop a Java application to automate basic banking operations using interfaces
and inheritance.
1. Define Interfaces:
o Create an interface named Transaction with methods
for deposit, withdraw, and viewBalance.
o Create another interface named Displayable with a display() method for
showing account details.
2. Create an Abstract Class:
o Define an abstract class Account that holds common bank account
details such as accName, accNo, and balance.
o Add necessary constructors to initialize these details.
3. Implement a Concrete Class:
o Create a Bank class that:
▪ Inherits from the Account class.

▪ Implements the Transaction and Displayable interfaces.


o Implement logic for each method according to the requirements of
banking operations.
4. Create a Main Class:
o Implement a menu-driven interface in the Main class that allows users
to perform the following operations:
▪ Deposit

▪ Withdraw
▪ Balance Inquiry
▪ View Account Details
Ensure each operation is handled appropriately by calling methods in
the Bank class.
Develop a Java application to automate banking operations using interfaces and an
abstract class.
1. Define Required Interfaces:
o Create an interface Transaction with methods for deposit, withdraw,
and viewBalance.
o Create a second interface Displayable with a display() method to show
account details.
2. Set Up an Abstract Base Class:
o Define an abstract class Account that stores bank account details
like accName, accNo, and balance.
o Include constructors to initialize account information.
3. Implement the Banking Logic:
o Create a Bank class that extends the Account class and implements
both Transaction and Displayableinterfaces.
o Provide specific implementations for each method
in Transaction and Displayable to perform core banking operations.
4. Develop a User Interface:
o In the main class, implement a menu-driven system that allows users
to:
▪ Deposit money

▪ Withdraw money
▪ Check account balance
▪ View account details
Design each menu option to call the appropriate methods in the Bank class and
execute corresponding banking operations.
Create a Java application that performs basic arithmetic and trigonometric
operations using interfaces and inheritance.
1. Define Interfaces:
o Create an interface MathsOperable with methods for basic arithmetic
operations: add, subtract, multiply, divide, and modulus.
o Create a second interface TrigonometricOperable with methods for
trigonometric operations: sine, cosine, and tan.
2. Create an Abstract Class:
o Define an abstract class Calculator that stores details such
as no1, no2, and result.
o Add necessary constructors to initialize the values of no1 and no2.
3. Implement Operations:
o Create a class Operation that:
▪ Implements both
the MathsOperable and TrigonometricOperable interfaces.
▪ Inherits from the Calculator class.

▪ Provides specific logic for performing arithmetic and


trigonometric operations.
4. Menu-Driven Execution:
o In the Main class, implement a menu-driven system that allows users
to choose from:
▪ Arithmetic operations: addition, subtraction, multiplication,
division, and modulus.
▪ Trigonometric operations: sine, cosine, and tangent.
o Call the appropriate methods from the Operation class to perform and
display the results of the operations.
Make sure to implement logic for each operation and handle inputs and outputs
accordingly.
Create a Java program that uses interfaces to perform basic arithmetic operations.
1. Define Interfaces:
o Create an interface MathsOperable with methods for basic arithmetic
operations: add, subtract, multiply, and divide.
2. Abstract Class for Calculator:
o Create an abstract class Calculator that contains
properties num1, num2, and result.
o Add a constructor to initialize num1 and num2.
3. Operation Class:
o Create a class Operation that:
▪ Implements the MathsOperable interface.

▪ Inherits from the Calculator class and provides the logic to


perform arithmetic operations (addition, subtraction,
multiplication, and division).
4. Menu-Driven Execution:
o In the Main class, create a simple menu that lets the user choose an
arithmetic operation:
▪ Add, subtract, multiply, or divide.
o Call the corresponding method from the Operation class to perform the
selected operation and display the result.
Write a Java program to perform matrix operations using multithreading. The
program should:
1. Prompt the user to enter the elements of two matrices.
2. Create three separate threads to perform the following operations on the
matrices:
o Matrix Addition
o Matrix Subtraction
o Matrix Multiplication
Each thread should perform its respective operation and output the result. The
program should use multithreading to perform the operations concurrently.

Develop a Java program that uses multithreading to perform the following operations
on two matrices:
1. Allow the user to input two matrices (A and B).
2. Create three threads, each performing one of the following operations:
o Matrix Addition: Add corresponding elements of the two matrices.
o Matrix Subtraction: Subtract the elements of matrix B from matrix A.
o Matrix Multiplication: Multiply matrix A by matrix B.
Each thread should compute its respective operation and print the resulting matrix.
Ensure the program makes use of multithreading to perform all operations
concurrently.
Write a Java program to perform the following tasks:
1. Create a file named first.txt and write the following content to it:
o "A stream is a communication channel that a program has with the
outside world. It is used to transfer data items in succession."
2. Create a second file named second.txt and write the following content:
o "An Input/Output (I/O) Stream represents an input source or an output
destination. A stream can represent many different kinds of sources
and destinations, including disk files, devices, other programs, and
memory arrays."
3. Merge the contents of first.txt and second.txt, and write the combined content
into a new file called final.txt.

Write a Java program that performs the following tasks:


1. Create a file named data1.txt and write the following content into it:
o "A stream is a communication channel that a program has with the
outside world. It is used to transfer data items in succession."
2. Create another file named data2.txt and write the following content:
o "An Input/Output (I/O) Stream represents an input source or an output
destination. A stream can represent many different kinds of sources
and destinations, including disk files, devices, other programs, and
memory arrays."
3. Read the contents of both data1.txt and data2.txt, and combine them into a
new file called mergedData.txt.
Create a Java Swing GUI application to implement a simple login functionality.
1. Design a login window with fields for the username and password, along with
a Login button.
2. If the user enters the username as "Karunya" and the password as "Karunya",
display a message box saying "Login Successful".
3. If the username or password is incorrect, show a message box with "Login
Failed".
The application should use basic Swing components
like JTextField, JPasswordField, JButton, and JOptionPane for message dialogs.

Develop a Java Swing GUI application to implement a user login feature.


1. Design a login window with fields for user ID and user password, along with
a Submit button.
2. If the user ID is "Admin" and the user password is "12345", display a
message box with the text "Access Granted".
3. If the user ID or user password is incorrect, display a message box
with "Access Denied".
Use appropriate Swing components such as JTextField, JPasswordField, JButton,
and JOptionPane to show message dialogs.

You might also like