0% found this document useful (0 votes)
12 views3 pages

Java Viva Preparation CSE310

The document contains a compilation of Java viva questions and answers covering various topics such as Java basics, arrays, object-oriented programming, inheritance, lambda expressions, I/O, generics, collections, and JDBC. Key concepts include the features of Java, differences between JDK, JRE, and JVM, and explanations of constructors, method overloading, and the use of functional interfaces. It serves as a study guide for students preparing for Java-related examinations.
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)
12 views3 pages

Java Viva Preparation CSE310

The document contains a compilation of Java viva questions and answers covering various topics such as Java basics, arrays, object-oriented programming, inheritance, lambda expressions, I/O, generics, collections, and JDBC. Key concepts include the features of Java, differences between JDK, JRE, and JVM, and explanations of constructors, method overloading, and the use of functional interfaces. It serves as a study guide for students preparing for Java-related examinations.
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
You are on page 1/ 3

Java Viva Questions & Answers - CSE310

Unit I - Java Basics

Q: What are the features of Java?

A: - Object-Oriented

- Platform Independent

- Simple and Secure

- Robust and Multithreaded

- High Performance

- Dynamic and Distributed

Q: Explain the role of JVM in Java.

A: JVM interprets bytecode into machine code, ensuring platform independence.

Q: Difference between JDK, JRE, and JVM?

A: - JDK: Development Kit (includes JRE + tools)

- JRE: Runtime Environment (includes JVM + libraries)

- JVM: Executes Java bytecode

Q: What is the default value of primitive data types?

A: int: 0, float: 0.0f, char: '\u0000', boolean: false

Q: How is `switch` different from `if-else`?

A: `switch` checks equality; `if-else` handles ranges and complex logic.

Unit II - Arrays, Enums & OOP

Q: Difference between `while` and `do-while`?

A: `while` checks condition first; `do-while` runs once before checking.

Q: Initialize a 2D array?

A: int[][] arr = new int[3][3];


Java Viva Questions & Answers - CSE310

Q: Constructor overloading?

A: Using multiple constructors with different parameters:

class Student {

Student() {}

Student(String name) {}

Q: Purpose of `this` keyword?

A: Refers to current class instance to resolve variable name conflicts.

Unit III - Inheritance & Interfaces

Q: Difference between method overloading and overriding?

A: Overloading: Same name, different parameters

Overriding: Same method in subclass

Q: Use of `super` keyword?

A: Calls superclass constructor or method.

Q: Can we instantiate abstract class?

A: No, we cannot create objects of abstract class.

Unit IV - Lambda & Nested Classes

Q: What is a functional interface?

A: Interface with one abstract method. Example: Runnable, Comparator

Q: Use of lambda expressions?

A: Concise syntax to implement functional interfaces. Runnable r = () -> System.out.println("Hi");

Q: Static vs non-static nested classes?

A: Static: no outer instance needed.


Java Viva Questions & Answers - CSE310

Non-static: requires outer class instance.

Unit V - I/O, Generics

Q: How to serialize an object?

A: Implement Serializable and use ObjectOutputStream.

Q: Use of generics in Java?

A: Enable type safety and avoid type casting.

Q: What are bounded type parameters?

A: Use <T extends ClassName> to restrict types.

Unit VI - Collections & JDBC

Q: ArrayList vs LinkedList?

A: ArrayList: Fast access, slow insert/delete

LinkedList: Fast insert/delete, slow access

Q: JDBC connection code?

A: Connection con = DriverManager.getConnection(url, "user", "pass");

Q: Comparable vs Comparator?

A: Comparable: implemented in class

Comparator: separate class with compare() method

You might also like