Question Bank
Question Bank
Design and implement a Java program to apply text processing techniques using
Java strings. Your program should:
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.
2. Implement constructors, getter, and setter methods for the `Student` class.
▪ 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
▪ 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.
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.