0% found this document useful (0 votes)
3 views2 pages

Java Viva Answers

The document provides a comprehensive overview of key Java OOP concepts including control structures, classes, objects, constructors, overloading, packages, strings, arrays, inheritance, polymorphism, interfaces, multithreading, and exception handling. It highlights important distinctions such as overloading vs overriding, interface vs abstract classes, and the differences between String, StringBuffer, and the use of the static keyword. The document serves as a study guide for Java OOP principles and practices.

Uploaded by

jeondeepshikha
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)
3 views2 pages

Java Viva Answers

The document provides a comprehensive overview of key Java OOP concepts including control structures, classes, objects, constructors, overloading, packages, strings, arrays, inheritance, polymorphism, interfaces, multithreading, and exception handling. It highlights important distinctions such as overloading vs overriding, interface vs abstract classes, and the differences between String, StringBuffer, and the use of the static keyword. The document serves as a study guide for Java OOP principles and practices.

Uploaded by

jeondeepshikha
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 OOP VIVA ANSWERS

1. Control Structures

Control structures are statements that control the flow of execution of a program.

Types: Selection (if, if-else, switch), Iteration (for, while, do-while), Jump (break, continue)

Switch:

- break terminates case

- without break → fall-through

- String allowed (Java 7), float/double not allowed

Loops:

- for → known iterations

- while → condition-based

- do-while → executes at least once

2. Class, Object, Constructor

Class = blueprint, Object = instance

Method = function inside class

this keyword → refers to current object

Encapsulation → wrapping data + methods

Constructor:

- Special method to initialize object

- Types: Default, Parameterized

- No return type

- Can be overloaded

3. Overloading, Packages, Static

Overloading → same method name, different parameters

Packages → collection of classes

Static → belongs to class, main is static so JVM can call it

4. Strings, Arrays, Vector

String → immutable

StringBuffer → mutable, thread-safe

StringBuilder → faster

Array → fixed size


ArrayList → dynamic

Vector → synchronized

5. Inheritance & Polymorphism

Inheritance → acquiring properties

Types: Single, Multilevel, Hierarchical

No multiple inheritance → avoids ambiguity

Polymorphism:

- Compile-time → overloading

- Runtime → overriding

6. Interface

Interface → collection of abstract methods

Supports multiple inheritance

No constructor

7. Multithreading

Thread → small unit of process

start() creates thread, run() executes

Synchronization avoids race condition

8. Exception Handling

Exception → runtime error

try, catch, finally, throw, throws

finally always executes

9. GUI (AWT, Swing)

AWT → basic GUI

Swing → advanced GUI

Event → user action, handled by listener

MOST IMPORTANT:

Overloading vs Overriding

Interface vs Abstract

String vs StringBuffer

Static keyword

Polymorphism → one entity many forms

You might also like