0% found this document useful (0 votes)
0 views6 pages

Java Module Wise Question Bank

The document is a comprehensive question bank for Java programming, organized into four modules covering topics such as OOP principles, classes and inheritance, interfaces and packages, as well as exception handling and multithreading. Each module contains multiple questions that test understanding of Java concepts, programming techniques, and practical coding skills. It serves as a study guide for learners to prepare for exams or enhance their Java programming knowledge.

Uploaded by

daipayankundu27
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)
0 views6 pages

Java Module Wise Question Bank

The document is a comprehensive question bank for Java programming, organized into four modules covering topics such as OOP principles, classes and inheritance, interfaces and packages, as well as exception handling and multithreading. Each module contains multiple questions that test understanding of Java concepts, programming techniques, and practical coding skills. It serves as a study guide for learners to prepare for exams or enhance their Java programming knowledge.

Uploaded by

daipayankundu27
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

Java Programming – Module Wise Question Bank

Module I – Introduction to OOP & Java Basics


1. Explain the working of the Java Virtual Machine (JVM) and how it contributes to the portability of Java applications.

2. Is the Java compiler platform-independent? Justify your answer.

3. Compare Java's primitive data types with reference data types.

4. In Java, encapsulation is achieved by bundling data and methods into a single unit called class — Explain with
example.

5. What role does JVM play to make Java a platform independent language?

6. Explain why Java is both portable and secure.

7. Write a Java program to check whether a given string is a palindrome or not.

8. What is the difference between String and StringBuffer class?

9. Explain with an example code that Java strings are immutable.

10. What is the output of [Link](10 + 20 + "30");?

11. Write a Java program to convert a String to an int and handle NumberFormatException.

12. Name the functions to take an integer, one word, and one line input from the user using Scanner class.

13. Discuss how command-line arguments are handled in Java.

14. Give example of Java command line argument handling.

15. Say a Java program named [Link] is compiled. What will it generate? How to run with command line
arguments?

16. Write a program to find the largest element in an array.

17. Write a program to reverse an array in place.

18. Write a program to swap two numbers without using a temporary variable.

19. Write a method that takes two integers and returns their sum.

20. Write a method to check if a number is prime and return true or false.

21. Print the first 10 Fibonacci numbers using a for loop.

22. Write a program that takes 5 numbers from the user and calculates their average.
23. Write a program that takes a user's name as input and greets them.

Module II – Classes, Objects, Inheritance & Nested Classes


1. What are constructors? What is meant by constructor overloading? Explain with example.

2. What is a constructor? How is it different from a method?

3. Explain the purpose of a constructor in Java.

4. Is it possible for a constructor to be private in Java? Explain with example.

5. Describe the process of object creation in Java using the new keyword.

6. Create a Student class with name and rollNo as attributes.

7. Add a method displayDetails() in Student class.

8. Create a Rectangle class with parameterized constructor.

9. What are the uses of the static keyword in Java?

10. Create a class Counter with a static variable count.

11. Briefly explain the use of this and super keywords.

12. What is the keyword this used for in Java?

13. What are the advantages of using Inner Class in Java?

14. What are the types of nested classes in Java? Explain briefly with examples.

15. Can we access non-static members of an outer class inside a static nested class?

16. State the differences between Inner Class and Static Nested class.

17. What is the difference between nested and inner class in Java?

18. What is the difference between static and non-static nested class in Java?

19. What is the difference of use of default and protected access specifier?

20. In Java, what are the key differences between public, protected, and default access specifiers?

21. What is package? What is the use of it?

22. Explain the use of packages in Java.

23. What is CLASSPATH?

24. Provide an example demonstrating how to create and use a package.


25. What are the key differences between function overloading and function overriding in Java?

26. Explain method overloading and method overriding with examples.

27. How do you implement compile-time polymorphism in Java?

28. Write code to display runtime polymorphism in Java.

29. What is inheritance? Give an example using extends.

30. Discuss how inheritance enhances code reusability in Java.

31. Create Vehicle and Car classes using inheritance.

32. What are the different uses of keyword super in Java?

33. What is the purpose of the super keyword? Give example.

34. What is the use of keyword final when used with class, method, variable?

35. What are the differences between final, finally, and finalize?

36. Provide examples demonstrating final, finally, and finalize.

37. What is the job of the finalize() method?

38. "Java does not support destructors" — Justify.

39. Is there any concept of destructor in Java?

40. Explain Garbage Collection and its importance.

41. Is it recommended to manually invoke garbage collector?

42. Name the parent class of all classes in Java.

43. What is the job of annotation @Override?

Module III – Interfaces, Generics & Packages


1. Write down the differences between interfaces and abstract classes.

2. Define abstract classes and interfaces.

3. What is an abstract method? How is it implemented in Java?

4. Write an example Java code showing the use of abstract class.

5. Can we instantiate an abstract class?

6. Why are abstract classes needed?


7. Which OOP concept is satisfied using abstract class?

8. Abstract class Shape has abstract method area() — write program.

9. What is Java’s solution to multiple inheritance?

10. Is it possible in Java to implement multiple inheritance? Explain with example.

11. Define Interfaces and explain with example.

12. Implementing interfaces in Java.

13. Extending interfaces in Java.

14. Interfaces and multiple inheritance.

15. What is partial implementation of an interface?

16. Can interface methods have method bodies?

17. What are the cases when interface methods can have method bodies?

18. With examples explain the scenario where the method in an interface can have a method body.

19. Explain Generic collection classes.

20. What is package? How do we add a class/interface to a package?

21. Explain Java API.

22. Explain user-defined packages.

23. Why do we need import statement?

24. Create package shape containing Circle, Triangle and Rectangle classes.

Module IV – Exception Handling, Multithreading & Swing


1. How do we define try and catch block in Java?

2. Explain when try, catch and finally are used.

3. Write the uses of finally block in Java.

4. Differentiate between checked and unchecked exception in Java.

5. What are exceptions?

6. Explain user defined exceptions and system defined exceptions.

7. What is the difference between throw and throws?


8. What is throw, throws and rethrow?

9. Write sample code for ArrayIndexOutOfBoundsException, ArithmeticException and NullPointerException.

10. Write Java program to convert String to int and handle NumberFormatException.

11. Create user-defined exceptions TooHot and TooCold.

12. Explain built-in exceptions in Java.

13. How do we define try and catch block? Is it essential to catch all exceptions?

14. Explain the output of try-catch-finally program given in question bank.

15. What is multithreading programming?

16. Explain thread life cycle.

17. Mention the different states of a thread.

18. How can you obtain the state of a thread?

19. What are the two approaches of creating thread in Java?

20. Explain difference between extending Thread and implementing Runnable.

21. Which thread creation approach do you prefer and why?

22. Write program to print name, priority and thread group.

23. Change the name of current thread to MyThread.

24. What is the default name of current executing thread?

25. What is synchronization and why is it needed?

26. What are the similarities and differences between synchronized method and synchronized block?

27. Write example of thread communication using wait() and notify().

28. What is deadlock?

29. What do you mean by context switch in Java threads?

30. Explain Java and multithreading.

31. Explain event delegation model.

32. What is event delegation model?

33. Write a Java swing program to add two numbers.

34. Explain any two methods of JFrame, JLabel and JPanel.


35. Write a program to explain event handling using Swing.

36. Write a Java program to draw polygon filled with green colour using rgb format.

37. Write Java applet program to reverse letters of a string.

38. Explain how to pass parameter to an applet.

You might also like