0% found this document useful (0 votes)
9 views5 pages

Java Viva Questions Class12 Finalprint

Uploaded by

Eshu Jain
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)
9 views5 pages

Java Viva Questions Class12 Finalprint

Uploaded by

Eshu Jain
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

Java Viva Questions & Answers (Class

12 IT - NCERT)
Why is Java called platform independent?
Because Java programs are compiled into bytecode, which can run on any system that has a
Java Virtual Machine (JVM).

What is JVM?
JVM stands for Java Virtual Machine. It is responsible for executing the Java bytecode.

What is the difference between = and == in Java?


= is the assignment operator, == is the comparison operator.

What is the purpose of public static void main(String[] args)?


It is the entry point of every Java program. public = accessible, static = runs without object,
void = no return, main = method name, String[] args = command line arguments.

Why is main() method static?


So that JVM can call it without creating an object of the class.

What is Scanner class in Java?


Scanner is a class in [Link] package used to take input from the user.

What is the difference between while and do-while loop?


while checks condition first, may execute 0 times. do-while executes at least once before
checking condition.

Explain the difference between for, while, and do-while loops.


for: used when iterations known, while: entry controlled, unknown iterations, do-while:
executes at least once.

What is the difference between break and continue?


break ends the loop, continue skips current iteration.

What is a class in Java?


A class is a blueprint for creating objects.

What is an object in Java?


An object is an instance of a class.

What is the purpose of new keyword?


It is used to create objects in Java.
What is the difference between [Link]() and [Link]()?
print() prints on same line, println() moves to next line.

Explain Arithmetic, Relational, and Logical operators.


Arithmetic: + - * / %, Relational: > < >= <= == !=, Logical: && || !

Explain variable and its types in Java.


Variable is a named memory location. Types: Primitive (int, float, etc.), Non-primitive
(String, Arrays, Objects).

Why is Java called Object Oriented?


Because it is based on concepts like class, object, inheritance, polymorphism, abstraction,
encapsulation.

What is bytecode?
It is intermediate code generated after compiling a Java program, which can run on any
system using JVM.

Difference between compiler and interpreter in Java?


Compiler (javac) converts source code into bytecode, Interpreter (JVM) executes the
bytecode line by line.

Example program questions


Cube of a number (while loop), Factorial program, Palindrome program, Switch-case menu
driven program.
Extended Java Viva Questions (Q20 -
Q40)
What is Java Development Kit (JDK)?
JDK is a software package that provides tools to develop and run Java programs. It contains
JRE + compiler + debugging tools.

What is Java Runtime Environment (JRE)?


JRE provides the libraries, JVM, and other files needed to run Java programs but does not
include compiler.

Difference between JDK, JRE, and JVM?


JVM runs the program (executes bytecode), JRE provides environment (JVM + libraries), JDK
provides development tools (JRE + compiler).

What is the difference between next() and nextLine() in Scanner?


next() reads a single word (till space), nextLine() reads a complete line including spaces.

What are wrapper classes in Java?


Wrapper classes convert primitive data types into objects. Example: Integer, Double,
Character, Boolean.

What is type casting in Java?


Type casting is converting one data type into another. Implicit (widening) automatic,
Explicit (narrowing) manual.

What is the difference between ++i and i++?


++i is pre-increment, increases value first. i++ is post-increment, uses value then increases
it.

What is difference between char and String in Java?


char stores a single character, String stores a sequence of characters.

What is an array in Java?


Array is a collection of elements of the same type stored in contiguous memory.

What is the difference between length and length()?


For arrays length is a property, for strings length() is a method.

What is method in Java?


A method is a block of code that performs a task.
What is method overloading?
When two or more methods in the same class have the same name but different parameters.

What is difference between local variable and instance variable?


Local variable is declared inside a method, accessible only inside it. Instance variable is
declared inside class but outside methods, accessible by objects.

What is a constructor in Java?


A special method used to initialize objects, same name as class, no return type, called
automatically.

What is the difference between constructor and method?


Constructor initializes objects, no return type, called automatically. Method performs task,
has return type, called manually.

What is inheritance?
Inheritance allows one class to acquire properties and methods of another class. Keyword:
extends.

What is polymorphism?
Polymorphism means many forms. Methods behave differently based on the object.
Examples: method overloading, overriding.

What is difference between final, finally, and finalize()?


final = keyword to make constant/stop inheritance, finally = block with try-catch, finalize()
= method before garbage collection.

What is exception handling?


Process of handling runtime errors using try, catch, finally, throw.

What is the difference between checked and unchecked exceptions?


Checked exceptions are checked at compile time (IOException), unchecked at runtime
(NullPointerException).

What is difference between equals() and == in Java?


== compares references (memory address), equals() compares contents of objects.
⚡ Last-Minute Revision Notes (Java
Class 12 IT)
• Java is platform-independent because of JVM and bytecode.

• JVM executes bytecode, JRE = JVM + libraries, JDK = JRE + compiler/tools.

• public static void main(String[] args) → entry point of program.

• Scanner class ([Link]) is used for input → next(), nextLine(), nextInt().

• = is assignment, == is comparison, equals() compares contents.

• while checks condition first, do-while runs at least once, for used when iterations are
known.

• break exits loop, continue skips current iteration.

• class = blueprint, object = instance, new keyword creates object.

• Constructor initializes objects, has no return type, same name as class.

• Method overloading = same name, different parameters.

• Arrays store multiple values of same type, [Link] (property), [Link]() (method).

• Wrapper classes convert primitives to objects (Integer, Double, etc.).

• Polymorphism → overloading & overriding, Inheritance → extends keyword.

• final = constant, finally = block with try-catch, finalize() = garbage collection method.

• Exception handling → try, catch, finally, throw.

• Checked exceptions → compile time, Unchecked → runtime.

• [Link]() → same line, println() → new line.

• ++i (pre-increment) increases first, i++ (post-increment) increases after use.

• char stores single character, String stores sequence of characters.

• Java is OOP → class, object, inheritance, polymorphism, abstraction, encapsulation.

You might also like