The document is a practice question set for a Java Programming course, covering various topics such as Object-Oriented Programming, Java execution environments (JDK, JVM, JRE), type casting, access specifiers, method overloading, exception handling, and multithreading. It includes programming tasks that require the implementation of concepts like collections, file handling, user-defined exceptions, and the use of JSP and servlets. The questions are designed to test understanding and practical application of Java programming principles.
The document is a practice question set for a Java Programming course, covering various topics such as Object-Oriented Programming, Java execution environments (JDK, JVM, JRE), type casting, access specifiers, method overloading, exception handling, and multithreading. It includes programming tasks that require the implementation of concepts like collections, file handling, user-defined exceptions, and the use of JSP and servlets. The questions are designed to test understanding and practical application of Java programming principles.
Practice question set 1. Explain the key features of Object-Oriented Programming (OOP) and how they are implemented in Java. Provide examples for at least two features. 2. Differentiate between JDK, JVM, and JRE. Illustrate their roles in Java program execution. 3. Describe the concept of type casting in Java. Differentiate between implicit and explicit type casting with examples. 4. 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 behavior of each access specifier. 5. 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. 6. Create a Java class with both static and non-static members. Write a program to call these members from the main method and explain the difference between their behavior. 7. Design a Java program that accepts a string as a command-line argument and checks whether it is a palindrome. Use StringBuffer or StringBuilder in your solution. 8. Develop a Java program that creates a user-defined exception to handle invalid input for a specific scenario (e.g., age below 18 for voting). Include a try-catch block to handle the exception. 9. 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. Include methods from each interface and call them in the main method. 10. 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. 11 Write a Java program to read data from a file using `BufferedReader` and write the processed output to another file using `BufferedWriter`. Include exception handling mechanisms to manage possible I/O errors. 12 Implement a Java program that demonstrates the difference between byte streams and character streams by reading and writing a text file using both approaches. 13. Explain how object serialization works in Java. 14.Design a Java program to demonstrate linked structures by implementing a simple singly linked list with operations like add, delete, and display. 15. 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. 16. Develop a Java program to simulate a queue using the `LinkedList` class from the Collections Framework. Include operations like enqueue, dequeue, and display. 17.Write a Java program to create multiple threads and assign different priorities to them. Observe and explain the impact of thread priority on their execution order. 18. Write a Java program to demonstrate the use of generic collections by implementing a `HashMap` to store and retrieve student details (e.g., roll number and name). Include operations to add, remove, and search for students. 19. What is method overriding in Java? What is basic Difference between Overriding and Overloading? 20. 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. 21. Differentiate between `Set` and `List` in the Java Collections Framework. Write a program to demonstrate their usage by storing and iterating over elements. 22.Explain the concept of object serialization in Java. Write a program to serialize and deserialize an object of a custom class that stores employee details. 23. Create a menu based calculator to perform various operations 24. Discuss the various access specifiers in Java. Create 2 packages P1 & P2 and create classes Student and BTech in P1 and P2 respectively. Check the accessibility of 3 methods of the package p1 into package p2. Access specifier of one method is private, one is protected and third one is default. 25Write a Java program to create a method that takes an integer as a parameter and throws an exception if the number is odd. 26Create a user defined exception “UnderageforVoting” exception and throw it when voter’s age is below 18. 27Write a Java program that creates a bank account with concurrent deposits and withdrawals using threads. 28Write a Java program using Anonymous class and override method in anonymous class. 29. Explain the concept of Polymorphism in Java, with suitable code. 30. Explain the role of constructors in Java. Write a program to demonstrate the difference between a default constructor and a parameterized constructor? 31. What is a Constructor? Explain types of Constructors in Java? Write a java program to find the Area of Circle using Constructor. 32.What is package in Java? Write a program to demonstrate, how to create and access user defined package in Java. 33. What is package? How do we create it? Write a program to create and to access package. 34. Write a Java program for creating four threads to perform the following operations i) Getting N numbers as input ii) Printing the even numbers iii) Printing the odd numbers iv) Computing the average. 35. With proper syntax and example explain following thread methods: wait( ) (2) sleep( ) (3) resume( ) (4) notify( ) 36. Write a java program to copy the content of the file “file1.txt” into new file “file2.txt”. 37. With neat diagram discuss about life cycle of thread and its priority 38. Explain the following keywords with example code: This 2) Abstract 3) Static 4) Final 39 What is Multithreading? Write a Java program that creates three threads. First thread displays “Hello!” in every one second, the second thread displays “Wear Mask!” in every two seconds and “Use Sanitizer!” in every 5 seconds. 40 Describe the following methods related to String. i) replace() ii) compareTo() iii) charAt() 41 Write a program that iterates over a Map (such as HashMap) and prints each key-value pair. 42. What are servlets? Discuss Servlet life cycle along with compilation and deployment of servlet with the help of a simple program. 43 What is AWT in Java programming? Explain the components of AWT. Differentiate between AWT and SWING technologies. 44 Describe how JSP files are compiled and executed within the web container. Explain how JSP fits into the overall web application architecture and the interaction between the client, server, and the JSP page. Write a code to display "Hello" message using JSP. 45 What is a stream in Java? Write a Java IO program to read & write in a File. 46 ExplainURL, IP addess, port number. How these all terms helps in creating socket. 47 Write a program that iterates over a Map (such as HashMap) and prints each key-value pair. 48 What are servlets? Discuss Servlet life cycle along with compilation and deployment of servlet with the help of a simple program. 49 Explain the differences between HashSet and TreeSet. Which one should you use when you need to maintain a sorted order? 50 How do JSP pages, servlets, and the Model-View-Controller (MVC) pattern interact in a typical web application? Describe the roles of each in the MVC architecture. 51 Develop a JAVA Application program (JDBC Program) for making connection with Employee Data Base and Reading the Employee Detail and Updating the Employee Detail. Employee Data BASE consist of Employee ID of Employee and Name of Employee and Department of Employee. 52 Explain Socket and Client-Server architecture in java networking. 53 What is basic difference between get Method and Post Method.Write a servlet program for retrieving parameter using Get Method. 54 Compare the architecture of a JSP page with that of a servlet. How do the roles of JSP and servlets complement each other in a web application? 55 What is File handling, Write a java program to copy the content of one file into another file. 56 Write a program using swing components to compute the factorial of a number? 57 What is the life cycle of a Servlet? Write a program to demonstrate the use of doget() and service() methods. 58 What are Cookies? How to create and delete cookoies in JSP 59 Create a form for student information. Write a JSP code to find total, average, result and grade of the Student. 60 Write a Java program for creating four threads to perform the following operations i) Getting N numbers as input ii) Printing the even numbers iii) Printing the odd numbers iv) Computing the average. 61 Explain the concept of object serialization in Java. Write a program to serialize and deserialize an object of a custom class that stores employee details.