Java Question
Java Question
Explain the key features of Object-Oriented Programming (OOP) and how they are implemented in
Java. Provide examples for at least two features
2.Describe the concept of type casting in Java. Differentiate between implicit and explicit type casting
with examples
3.Write a Java program to demonstrate the use of access specifiers by creating a class with fields and
methods having different access levels. Explain the behaviour of each access specifier.
4.Develop a Java program to showcase method overloading by creating methods with the same
name but different parameter lists. Include at least three overloaded methods.
5.Explain the difference between `abstract` classes and `interfaces` in Java. Write a Java program to
implement an `Interface` and demonstrate how a class can implement multiple interfaces.
6.Create a Java program to demonstrate the use of `ArrayList` and `HashMap` from the Collections
Framework. Perform basic operations such as adding, removing, and iterating over elements.
7.Design a Java program to demonstrate linked structures by implementing a simple singly linked list
with operations like add, delete, and display.
8. Write a Java program to implement exception handling strategies by demonstrating the use of `try-
catch-finally` and `throws` keywords with a scenario involving division by ZERO
9.What is method overriding in Java? What is basic Difference between Overriding and Overloading?
10.Describe the steps involved in creating and using a user-defined exception in Java. Write a Java
program to handle an invalid bank transaction using a custom exception class.
11.Write a java program to find the number of and sum of all integers greater than 50 and less than
100 and are prime numbers
13.Write a Java recursive method to check if a given array is sorted in ascending order
14.Write a Java program that creates a bank account with concurrent deposits and withdrawals using
threads.
15.Write a JAVA Program to demonstrate Constructor overloading and Method overloading. Also
access parent class constructor in child class
16.Create a class Student (name, roll_no, marks) with one method show() and initialize instance
variables using all the ways: reference, method and constructor
17.Develop a Java program to demonstrate thread synchronization using the `synchronized` keyword.
Create a scenario where multiple threads access a shared resource, and synchronize the access to
prevent data inconsistency
18.
Write a Java program to create an interface Shape with the getArea() method. Create three classes
Rectangle, Circle, and Triangle that implement the Shape interface. Implement the getArea() method
for each of the three classes.
19.
class X{
20.Write a Java program in which inherit one abstract class and implement methods of 3 interfaces.
One interface is containing default method and static method
21.
Write a Java program to create a method that takes an integer as a parameter and throws an
exception if the number is odd.
22.
Write a Java program to create an abstract class Employee with abstract methods calculateSalary()
and displayInfo(). Create subclasses Manager and Programmer that extend the Employee class and
implement the respective methods to calculate salary and display information for each role.
23.
24.
Develop a Java program to simulate a queue using the `LinkedList` class from the Collections
Framework. Include operations like enqueue, dequeue, and display
25.Differentiate between JDK, JVM, and JRE. Illustrate their roles in Java program execution.