Java Important Questions
Java Important Questions
1. What is abstraction?
2. Is Java platform-independent?
3. What is the use of this keyword?
4. What is a package in Java?
5. What is the purpose of a constructor?
6. Can a constructor be overloaded in Java?
7. Which method is the entry point of a Java program?
8. What is exception handling in Java?
9. What is the return type of a constructor?
10. What is the size of an int in Java?
11. Why doesn’t Java support multiple inheritances directly?
12. What is the use of the finally block?
13. Explain the concept of inheritance briefly.
14. What are access modifiers in Java?
15. What are wrapper classes in Java?
16. What is an ArithmeticException?
17. What is the difference between JDK and JRE?
18. What is polymorphism in Java?
19. Which class is used to implement a socket in Java?
20. What is a socket in Java?
SECTION-B
SECTION-C
1. What are command-line arguments in Java? Explain with Practical example how they are passed
to a Java program.
2. Discuss encapsulation in Java. How does it help in writing secure and maintainable code?
Provide a real-world example.
3. Explain the different types of operators in Java. Illustrate each with a suitable example.
4. What is polymorphism in Java? Differentiate between compile-time and run-time polymorphism
with code examples.
5. What is method overriding in Java? Explain how it is different from method overloading. Provide
a real-world example where method overriding is necessary for implementing polymorphism.
6. What is the difference between sleep() and wait()?
7. What are the different types of decision-making statements in Java? Explain each with
examples.
8. What is the lifecycle of a thread in Java? Explain the different states of a thread.
a. Explain the concept of abstract classes and abstract methods.
b. Write a Java program that demonstrates the use of sleep() and join() methods.
9. What is a wrapper class? Give examples.
10. What is the process of creating an exception subclass in Java? Discuss how a custom exception
can be created by extending either the Exception or RuntimeException class.
11.
12. Explain the different types of events in Java AWT with example.
13. What are the different states of a servlet life cycle? Explain the various phases of servlet life
cycle.
14. What is a JAR (Java Archive) file in Java? Discuss its structure and explain how to create a JAR
file in Java using the jar command. Provide the steps and an example.