0% found this document useful (0 votes)
6 views7 pages

Java Sample Questions

The document outlines the fundamentals of Object-Oriented Programming (OOP), including key concepts such as classes, objects, encapsulation, inheritance, polymorphism, and abstraction. It covers Java programming language specifics, including its features, data types, control structures, error handling, and file handling. Additionally, it provides unit-wise questions for deeper understanding and application of the concepts discussed.

Uploaded by

eclearning360
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views7 pages

Java Sample Questions

The document outlines the fundamentals of Object-Oriented Programming (OOP), including key concepts such as classes, objects, encapsulation, inheritance, polymorphism, and abstraction. It covers Java programming language specifics, including its features, data types, control structures, error handling, and file handling. Additionally, it provides unit-wise questions for deeper understanding and application of the concepts discussed.

Uploaded by

eclearning360
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

UNIT 1: Fundamentals of OOP

1. What is Object-Oriented Programming?


OOP is a programming paradigm based on objects and classes.
2. What is an object?
An object is an instance of a class.
3. What is a class?
A class is a blueprint for creating objects.
4. Define encapsulation.
Encapsulation is wrapping data and methods into a single unit.
5. Define inheritance.
Inheritance is acquiring properties of one class into another.
6. What is polymorphism?
Polymorphism allows methods to perform different tasks.
7. What is abstraction?
Abstraction hides implementation details.
8. Mention one benefit of OOP.
Code reusability.
9. What is Java?
Java is a high-level, object-oriented programming language.
10. Who developed Java?
James Gosling.
11. What is JVM?
Java Virtual Machine executes Java bytecode.
12. What is bytecode?
Intermediate code generated by Java compiler.
13. What is JDK?
Java Development Kit.
14. What is JRE?
Java Runtime Environment.
15. What are Java tokens?
Smallest units of a Java program.
16. Name any one token type.
Keyword.
17. What is a keyword?
Reserved word in Java.
18. What is an identifier?
Name given to variables or methods.
19. What is a literal?
Constant value.
20. What is a statement?
A complete instruction in Java.

UNIT 2: Branching and Looping


1. What is a variable?
A container for storing data.
2. What is a constant?
A value that cannot be changed.
3. What is a data type?
Specifies the type of data.
4. Name any primitive data type.
int.
5. What is an operator?
Symbol used to perform operations.
6. What is an expression?
Combination of variables and operators.
7. What is decision making?
Choosing a path based on condition.
8. What is if statement?
Conditional statement.
9. What is if-else statement?
Executes one of two blocks.
10. What is nested if?
if inside another if.
11. What is switch statement?
Multi-way branching statement.
12. What is ternary operator?
Short form of if-else.
13. What is looping?
Repeating a block of code.
14. What is while loop?
Entry-controlled loop.
15. What is do-while loop?
Exit-controlled loop.
16. What is for loop?
Loop with initialization, condition, increment.
17. What is break statement?
Terminates loop.
18. What is continue statement?
Skips iteration.
19. What is a class?
Blueprint for objects.
20. What is a method?
Function inside a class.

UNIT 3: Arrays and Interfaces


1. What is an array?
Collection of similar data types.
2. What is array index?
Position of element.
3. What is a string?
Sequence of characters.
4. What is String class?
Class used to handle strings.
5. What is a vector?
Dynamic array.
6. What is an interface?
Collection of abstract methods.
7. Can interface have variables?
Yes, constants.
8. What is multiple inheritance?
Inheriting from multiple classes.
9. How is multiple inheritance achieved in Java?
Using interfaces.
10. What is a package?
Collection of classes.
11. Why packages are used?
For organization.
12. What is multithreading?
Executing multiple threads.
13. What is a thread?
Smallest unit of process.
14. What is thread lifecycle?
States of thread execution.
15. Name one thread state.
Running.
16. What is synchronization?
Controlling thread access.
17. Difference between array and vector?
Array is fixed, vector is dynamic.

UNIT 4: Error Handling


1. What is an exception?
Runtime error.
2. What is error?
Serious problem.
3. What is exception handling?
Managing runtime errors.
4. What is try block?
Code that may cause exception.
5. What is catch block?
Handles exception.
6. What is finally block?
Executes always.
7. What is throw keyword?
Used to throw exception.
8. What is throws keyword?
Declares exceptions.
9. What is checked exception?
Checked at compile time.
10. What is unchecked exception?
Occurs at runtime.
11. What is an applet?
Java program for web browser.
12. What is applet lifecycle?
Stages of applet execution.
13. Name one lifecycle method.
init().
14. What is graphics class?
Used for drawing.
15. What is paint() method?
Used to draw graphics.

UNIT 5: File Handling in Java


1. What is a stream?
Flow of data.
2. What is input stream?
Reads data.
3. What is output stream?
Writes data.
4. What is byte stream?
Handles binary data.
5. What is character stream?
Handles text data.
6. Name one byte stream class.
FileInputStream.
7. Name one character stream class.
FileReader.
8. What is File class?
Represents file.
9. What is file creation?
Creating new file.
10. What is I/O exception?
Error during input/output.
11. What is reading file?
Getting data from file.
12. What is writing file?
Storing data in file.
13. What is primitive data type handling?
Reading/writing basic data types.
14. What is random access file?
Access file at any position.
15. What is EOF?
End of file.
5 MARK QUESTIONS (UNIT-WISE)

UNIT 1: Fundamentals of OOP

1. Explain the basic concepts of Object-Oriented Programming.


2. List and explain the benefits of OOP.
3. Write a note on applications of OOP.
4. Explain the features of Java.
5. Compare Java with C and C++ (any five points).
6. Describe the structure of a Java program.
7. What are Java tokens? Explain types with examples.
8. Explain the role of Java Virtual Machine (JVM).
9. Write a short note on Java and Internet.
10. Explain how Java supports web browsers.

UNIT 2: Branching and Looping

1. Explain data types in Java with examples.


2. Write a note on operators and expressions.
3. Explain if and if-else statements with examples.
4. Describe the switch statement with syntax.
5. Explain the ternary (? :) operator.
6. Write a note on while and do-while loops.
7. Explain the for loop with example.
8. What are jump statements? Explain break and continue.
9. What are labeled loops?
10. Explain classes and objects in Java.

UNIT 3: Arrays and Interfaces

1. Explain arrays in Java with example.


2. Write a note on strings in Java.
3. Explain vectors in Java.
4. What is an interface? Explain with example.
5. Explain multiple inheritance using interfaces.
6. What are packages in Java?
7. Explain how classes are grouped using packages.
8. Write a note on multithreading.
9. Explain thread lifecycle.
10. Differentiate array and vector.

UNIT 4: Error Handling

1. Define exception handling in Java.


2. Explain types of exceptions.
3. Write a note on try-catch block.
4. Explain throw and throws keywords.
5. What is finally block?
6. Write a note on applet programming.
7. Explain applet lifecycle.
8. Write a note on graphics programming in Java.
9. Explain paint() method.
10. Differentiate error and exception.

UNIT 5: File Handling in Java

1. Define streams in Java.


2. Explain byte stream classes.
3. Explain character stream classes.
4. Write a note on File class.
5. Explain I/O exceptions.
6. Write a note on file creation in Java.
7. Explain reading and writing characters.
8. Write a note on random access file.
9. Explain handling primitive data types in I/O.
10. Differentiate byte stream and character stream.

8 MARK QUESTIONS (UNIT-WISE)

UNIT 1: Fundamentals of OOP

1. Explain the object-oriented paradigm and its key concepts in detail.


2. Discuss the advantages and applications of OOP with examples.
3. Describe the history and evolution of Java.
4. Explain Java features in detail with examples.
5. Compare Java with C and C++ in detail.
6. Explain the structure of a Java program with example.
7. Describe Java tokens, statements, and expressions with examples.
8. Explain the working of JVM architecture.

UNIT 2: Branching and Looping

1. Explain constants, variables, and data types in Java with examples.


2. Discuss operators and expressions in detail.
3. Explain decision-making statements (if, nested if, switch) with examples.
4. Explain looping statements (while, do-while, for) with examples.
5. Discuss jump statements and labeled loops with examples.
6. Explain classes, objects, and methods in Java with a program.
7. Write a Java program demonstrating branching and looping.

UNIT 3: Arrays and Interfaces

1. Explain arrays, strings, and vectors in Java with examples.


2. Discuss interfaces and implementation with suitable programs.
3. Explain multiple inheritance using interfaces with example.
4. Describe packages in Java and their advantages.
5. Explain creating and using packages with example.
6. Discuss multithreaded programming in Java.
7. Explain thread lifecycle and synchronization.

UNIT 4: Error Handling

1. Explain exception handling mechanism in Java with examples.


2. Discuss different types of exceptions and handling techniques.
3. Explain try, catch, finally, throw, and throws with examples.
4. Describe applet programming with lifecycle methods.
5. Explain graphics programming in Java with example.
6. Write a Java program demonstrating exception handling.

UNIT 5: File Handling in Java

1. Explain Java I/O streams and their classification.


2. Discuss byte streams and character streams with examples.
3. Explain File class and file operations in Java.
4. Describe reading and writing data using streams.
5. Explain handling primitive data types using I/O streams.
6. Discuss random access files with example.
7. Write a Java program for file creation and reading/writing data.

You might also like