0% found this document useful (0 votes)
23 views1 page

Java Important Questions for Exams

Uploaded by

omyaa122
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)
23 views1 page

Java Important Questions for Exams

Uploaded by

omyaa122
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 IMPORTANT QUESTIONS

UNIT-I

1. Explain the java features?


2. Briefly explain about JVM with neat diagram?
3. What are the data types in java?
4. What are branching statements in java ? explain with examples
5. What are loops in java? how it works
6. What is class and object?Explain about class and object creation?
7. What is method overloading?

UNIT-II

8. What is a constructor? What are the types of constructors?what is constructor overloading?


9. what is garbage collector?
10. Explain about static and this keywords?
11. Explain about arrays in java? write a java program to perform matrix multiplication.
12. What is inheritance and what are the types of inheritance?
13. Explain about super and final keyword?
14. What is method overriding?explain with example?
15. What are abstract classes in java?
16. What are interfaces in java?
17. What are the differences between abstract class and interface?
18. What are packages in java?
19. Explain about wrapper classes in java?
20. Explain String handling in java?

UNIT-III

21. What is Exception in java? What are types of exceptions ? What are the Exception handling Techniques?
22. Whast is Multithreding? How to create a thread in java?
23. Explain about thread life cycle?
24. What is IO package in java?what are streams?
25. Write a java program to perform read and write operations?
26. Explain RandomAccessFile class methods?
27. Explain Scanner class?
28. Explain about BufferedInputStream and BufferedOutputStream?
29. Explain about FileReader abd FileWriter class

UNIT-IV

30. What is Applet?Write a simple Applet program?


31. What are the methods in Applet Class? What is Applet Lifecycle.
32. What is an Event? What are the types of Events?
33. What are the differences between AWT & Swings?
34. Explain about Layout Managers ?
35. What is Jdbc? What are types of Jdbc Drivers?
36. What are steps to develop a jdbc Application?

Common questions

Powered by AI

Method overloading occurs within a class, allowing multiple methods to have the same name with different parameter lists, providing compile-time polymorphism. It's used to enhance code readability and reusability. Method overriding, on the other hand, involves redefining a method in a subclass that already exists in its superclass, enabling runtime polymorphism. Overriding is crucial for implementing inheritance-based frameworks, allowing specific behavior modifications in subclasses. Use case for overloading: a print method that accepts different data types. Use case for overriding: redefining a calculateSalary method in subclasses of an Employee superclass for different employee types.

Java supports single, multilevel, and hierarchical inheritance. Single inheritance allows a class to inherit from one superclass, simplifying the class hierarchy and avoiding complexities of multiple inheritances, which Java does not support directly to eliminate ambiguity. Multilevel inheritance spans multiple levels of subclasses derived from one superclass, forming a chain. Hierarchical inheritance allows multiple subclasses to inherit from one superclass, promoting code reusability. These inheritance types enable effective hierarchy structuring, encapsulation of common behavior and code reuse in Java applications, facilitating maintainability.

Exception handling in Java contributes to program stability by allowing a program to deal with errors gracefully without crashing. Java employs try-catch blocks as a primary method for handling exceptions, where potentially problematic code is placed within a 'try' block, and exceptions are caught in subsequent 'catch' blocks. The 'finally' block can be used to execute code regardless of whether an exception occurs, ensuring resource cleanup. Java's catch blocks allow catching specific exceptions, leading to more precise error handling. Long-term program stability is enhanced through effective use of custom exceptions and layered exception handling strategies.

AWT is Java's original platform-dependent windowing, graphics, and user-interface widget toolkit, which relies on the local system's windowing toolkit, making applications appear differently depending on the platform. Swing, however, is a part of the Java Foundation Classes (JFC) and provides a more sophisticated set of GUI components that are lightweight, platform-independent, and consistent across platforms. Swing supports pluggable look-and-feel, which means the UI can be changed without affecting the code logic. Swing is often preferred over AWT for modern Java applications due to its richer functionality, flexibility, and consistent appearance, despite AWT's slightly better performance in some cases.

Java is a platform-independent language due to the Java Virtual Machine (JVM), which allows Java programs to run on any device that has the JVM installed. It supports object-oriented concepts such as inheritance, encapsulation, and polymorphism, providing a robust structure for managing complex software systems. Java also features automatic memory management and garbage collection, reducing the risk of memory leaks and enhancing efficiency. Moreover, it has a rich standard library, which simplifies the development of networked and graphical applications. These features have contributed to Java's widespread adoption in various domains, including web development, Android app development, and enterprise solutions.

The 'static' keyword in Java signifies that a method or variable belongs to the class, rather than instances of the class, useful for constants and methods common across all objects. It supports memory management efficiency by sharing the attribute among all instances. The 'this' keyword refers to the current instance of a class and is employed to resolve variable name conflicts and pass the current class instance as a parameter. Both keywords facilitate clear, efficient code management, enhancing the design and implementation of object-oriented structures.

Abstract classes in Java are used to define classes that cannot be instantiated but can provide a base with both complete and incomplete methods for subclasses. Unlike interfaces, abstract classes can contain fields, constructors, and methods with implementation. Interfaces, conversely, are contracts that can contain default methods and constant variables but before Java 8, they only contained method signatures. Use cases for abstract classes include situations where shared behavior needs to be encapsulated and possibly shared variables. Interfaces are ideal for achieving multiple inheritance and defining functionalities that are not necessarily related by hierarchical inheritance.

The JVM acts as an abstract computing machine that enables Java bytecode to be executed on any platform, facilitating Java's platform independence. Its core responsibilities include loading bytecode, verifying it for security, executing it, and providing runtime environment management. The JVM handles memory allocation for Java objects and has an in-built garbage collector to reclaim memory. It also supports load distribution and handles exceptions, ensuring robustness during execution.

Branching statements in Java, such as if-else, switch, and ternary operators, control the flow of a program by enabling decisions based on conditions. They guide the execution path based on boolean expressions. For example, 'if-else' is used to execute certain code blocks conditionally: if (condition) { //code if true } else { //code if false }. The 'switch' statement facilitates multi-way branching based on variable values, making code clearer and more organized in scenarios with multiple conditions.

Multithreading in Java allows simultaneous execution of two or more threads for maximum utilization of CPU. It contributes to the responsiveness of applications, especially for tasks such as GUI or real-time processing, by performing background operations concurrently. To create a thread in Java, one can extend the Thread class and override its run method, or implement the Runnable interface and pass it to a Thread object. Then, call the start method on a thread instance to initiate it. These methods allow Java applications to manage thread execution and synchronization effectively.

You might also like