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

Java Viva Questions Class12

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)
29 views2 pages

Java Viva Questions Class12

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
You are on page 1/ 2

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 java.util 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 System.out.print() and System.out.println()?
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.

You might also like