0% found this document useful (0 votes)
2 views4 pages

Java Important Questions Answers

The document provides a comprehensive overview of important Java concepts, including Object Oriented Programming principles, Java program structure, exception handling, threading, and file handling. It covers key topics such as classes and objects, inheritance, AWT components, and Java I/O streams, along with their respective functionalities and examples. Additionally, it discusses the Java environment, error classification, and multithreading, making it a valuable resource for understanding Java programming.

Uploaded by

ncayl950
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)
2 views4 pages

Java Important Questions Answers

The document provides a comprehensive overview of important Java concepts, including Object Oriented Programming principles, Java program structure, exception handling, threading, and file handling. It covers key topics such as classes and objects, inheritance, AWT components, and Java I/O streams, along with their respective functionalities and examples. Additionally, it discusses the Java environment, error classification, and multithreading, making it a valuable resource for understanding Java programming.

Uploaded by

ncayl950
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 and Answers

1. Explain the basic principles of Object Oriented Programming.


OOP is based on four main principles: Encapsulation (binding data and methods together),
Inheritance (acquiring properties of another class), Polymorphism (same method behaving
differently), and Abstraction (showing only essential features and hiding implementation).

2. Explain the structure of a simple Java program and describe Java tokens.
A Java program generally contains: package declaration, import statements, class definition, main()
method, statements, and comments. Java tokens are the smallest elements of a program such as
keywords, identifiers, literals, operators, and separators.

3. Explain Labelled Loops – break and continue.


A labelled loop allows naming a loop. 'break label;' terminates the specified loop while 'continue
label;' skips the current iteration and continues with the next iteration of the labelled loop.

4. Explain Classes and Objects in Java.


A class is a blueprint used to create objects. It defines properties and behaviors. An object is an
instance of a class that contains real values and can call methods.

5. Explain Inheritance in Java with an example.


Inheritance allows one class to inherit properties of another class using 'extends'. It promotes code
reuse. Example: class Animal { } class Dog extends Animal { }

6. Describe the Life Cycle of a Thread in Java.


The thread life cycle includes: New, Runnable, Running, Waiting/Blocked, and Terminated states.

7. Explain the types of Exceptions in Java.


Exceptions are of two types: Checked exceptions (checked at compile time like IOException) and
Unchecked exceptions (occur at runtime like ArithmeticException).

8. What are containers in AWT?


Containers are components that can hold other components. They help organize GUI elements.

9. Explain the concept of Streams in Java.


Streams represent a flow of data used for input and output operations. They allow reading or writing
data from sources like files, keyboard, or network.

10. Explain the File class and I/O Exceptions in Java.


The File class provides methods for file handling such as creating, deleting, and checking files. I/O
exceptions occur during input-output operations.
11. Describe the Java environment and architecture.
The Java environment consists of JDK, JRE, and JVM. Java source code is compiled into bytecode
which is executed by JVM making Java platform independent.

12. Explain decision-making statements in Java.


Decision-making statements control program flow. Examples include if, if-else, nested if, and
switch.

13. Describe looping statements in Java.


Looping statements repeat execution of a block of code. Types include for loop, while loop, and
do-while loop.

14. Classify the types of errors in Java.


Errors can be classified as Compile-time errors, Runtime errors, and Logical errors.

15. Describe Java Threads.


Threads allow concurrent execution of two or more parts of a program. They improve efficiency and
performance in multitasking applications.

16. Explain the life cycle of a Java Applet.


The stages are Initialization (init), Starting (start), Running (paint), Stopping (stop), and Destruction
(destroy).

17. Explain AWT Components and Event Handling.


AWT components include Button, Label, TextField, Checkbox etc. Event handling allows programs
to respond to user actions like button clicks.

18. Explain Java I/O Stream hierarchy.


The I/O stream hierarchy includes Byte Streams (InputStream, OutputStream) and Character
Streams (Reader, Writer).

19. Discuss file handling in Java.


File handling allows reading, writing, and modifying files using classes such as FileReader,
FileWriter, BufferedReader, and BufferedWriter.

20. Explain the core concepts of OOP with examples.


Core concepts include Encapsulation, Inheritance, Polymorphism, and Abstraction. Example: a
Vehicle class and Car class demonstrating inheritance.

21. Describe the structure of a Java program.


A Java program contains class declaration, main method, variables, statements, and methods.

22. Explain break and continue statements with labeled loops.


'break' exits a loop immediately while 'continue' skips the current iteration. When used with labels
they affect outer loops.

23. Discuss the concept of classes and object creation.


Objects are created using the 'new' keyword. Example: Student s = new Student();

24. Explain types of inheritance in Java.


Types include Single, Multilevel, Hierarchical, and Hybrid inheritance (through interfaces).

25. Describe stages in the thread life cycle.


The stages are New, Runnable, Running, Waiting/Blocked, and Terminated.

26. Explain checked and unchecked exceptions.


Checked exceptions are checked at compile time while unchecked exceptions occur during
runtime.

27. Describe AWT containers.


Containers are divided into top-level containers (Frame, Dialog) and general containers (Panel,
ScrollPane).

28. Explain byte streams and character streams.


Byte streams handle binary data while character streams handle character data.

29. Discuss the role of File class in Java.


The File class is used to create files, check file properties, and manage directories.

30. Explain Java environment including JDK, JRE, JVM.


JDK provides development tools, JRE provides runtime environment, and JVM executes bytecode.

31. Explain features of Java.


Important features include platform independence, object orientation, security, robustness,
multithreading, and portability.

32. Explain conditional and looping statements.


Conditional statements control decisions while loops execute repeated tasks.

33. Classify different types of errors.


Compile-time errors occur during compilation, runtime errors occur during execution, and logical
errors produce incorrect output.

34. Describe multithreading in Java.


Multithreading allows multiple threads to run simultaneously improving performance.
35. Explain Java I/O stream hierarchy with diagram.
Java I/O streams are divided into InputStream/OutputStream for byte streams and Reader/Writer
for character streams.

36. Explain exception handling with try, catch, throw, finally.


try contains risky code, catch handles exceptions, throw explicitly throws an exception, and finally
executes important cleanup code.

You might also like