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

Java Theory Notes Class12 IT802

The document provides comprehensive theory notes on Java Programming for Class 12, covering fundamental concepts such as Java's features, control statements, arrays, methods, classes, exception handling, and file handling. It includes basic questions and answers that explain key terms and principles, such as JVM, data types, loops, and object-oriented programming concepts like inheritance and polymorphism. Additionally, it highlights the differences between various programming constructs and provides examples to illustrate these concepts.

Uploaded by

Pinki Solanki
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)
5 views3 pages

Java Theory Notes Class12 IT802

The document provides comprehensive theory notes on Java Programming for Class 12, covering fundamental concepts such as Java's features, control statements, arrays, methods, classes, exception handling, and file handling. It includes basic questions and answers that explain key terms and principles, such as JVM, data types, loops, and object-oriented programming concepts like inheritance and polymorphism. Additionally, it highlights the differences between various programming constructs and provides examples to illustrate these concepts.

Uploaded by

Pinki Solanki
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

Class 12 – Java Programming (IT 802) Complete Theory Notes (With Questions & Answers)

---------------------------------------- 1. BASIC QUESTIONS ----------------------------------------


Q14. What is Java? Answer: Java is a high-level, object-oriented programming language developed
by James Gosling at Sun Microsystems in 1995. It is platform-independent and used to create
desktop, web, and mobile applications.
Q15. Write any five features of Java. Answer: 1. Object-Oriented 2. Platform Independent 3. Secure
4. Robust 5. Multithreaded
Q16. What is JVM, JRE, and JDK? Answer: • JVM (Java Virtual Machine): Runs the compiled Java
bytecode. • JRE (Java Runtime Environment): Provides libraries and JVM to run Java programs. •
JDK (Java Development Kit): Includes JRE, compiler, and tools for developing programs.
Q17. What is the difference between compiler and interpreter? Answer: Compiler translates the
entire program at once, while Interpreter translates line by line. Java uses both (javac and JVM).
Q18. What do you mean by platform independence in Java? Answer: Java programs run on any
system having JVM. Once compiled, bytecode can be executed anywhere.
Q19. What is bytecode? Answer: Bytecode is the intermediate code generated by Java compiler
(.class file) which is executed by JVM.
Q20. What are variables and data types in Java? Answer: Variables are names for memory
locations. Data types define the type of data stored (int, float, char, etc.).
Q21. What is the difference between primitive and non-primitive data types? Answer: Primitive:
Predefined (int, char, boolean). Non-primitive: User-defined (String, Array, Class).
Q22. What are operators in Java? Answer: Operators perform operations on data. Types include
arithmetic (+,-,*), relational (>,<), logical (&&,||), assignment (=).
Q23. Define identifier and literals. Answer: Identifier: User-defined name (e.g., sum). Literal: Fixed
values (e.g., 10, "Java").
---------------------------------------- 2. CONTROL STATEMENTS ----------------------------------------
Q1. What are conditional statements? Answer: Conditional statements control program flow based
on conditions (if, if-else, switch).
Q2. Explain if, if-else, and nested if with example. Answer: if – Executes code when condition is
true. if-else – Executes one block if true, another if false. nested if – Multiple conditions inside one
another.
Example: if(a>0){System.out.println("Positive");}
Q3. What is a switch statement? Answer: Used for multiple conditions. Syntax:
switch(variable){case 1: ...; break; default: ...;}
Q4. What are loops? Answer: Loops execute code repeatedly. Types: for, while, do-while.
Q5. Difference between break and continue. Answer: break – exits loop. continue – skips current
iteration.
Q6. Entry vs Exit Controlled Loops: Entry: Condition checked first (for, while) Exit: Condition
checked after execution (do-while).
---------------------------------------- 3. ARRAYS AND STRINGS ----------------------------------------
Q1. What is an array? Answer: Collection of similar data stored under one name.
Q2. Declaration & Initialization: int[] a = {1,2,3};
Q3. 1D vs 2D arrays: 1D – Single row; 2D – rows and columns.
Q4. What is a String? Answer: Sequence of characters. Example: String s="Java";
Q5. String vs StringBuffer: String is immutable, StringBuffer is mutable.
Q6. Two String methods: length() – returns length. toUpperCase() – converts to uppercase.
---------------------------------------- 4. FUNCTIONS / METHODS ----------------------------------------
Q1. What is a method? Answer: Block of code executed when called.
Q2. Call by value vs call by reference: Value – copy of data sent. Reference – actual reference
sent.
Q3. What is method overloading? Answer: Same method name, different parameters.
Q4. Why use return statement? Answer: To return value from method.
Q5. What is recursion? Answer: Method calling itself. Example: factorial(n){ if(n==1) return 1; else
return n*factorial(n-1); }
---------------------------------------- 5. CLASSES AND OBJECTS ----------------------------------------
Q1. Define class and object. Class – Blueprint of objects. Object – instance of class.
Q2. Difference: Class is logical; Object is physical entity.
Q3. Constructor: Special method to initialize objects.
Q4. Default vs Parameterized: Default – no parameters. Parameterized – parameters given.
Q5. this keyword: Refers to current object.
Q6. Encapsulation: Binding data and code together (using classes).
Q7. Inheritance: Acquiring properties from another class. Types: single, multilevel, hierarchical.
Q8. Polymorphism: Ability of same function to act differently (overloading/overriding).
Q9. Data abstraction: Hiding internal details, showing only essentials.
Q10. Access specifiers: public, private, protected, default.
---------------------------------------- 6. EXCEPTION HANDLING ----------------------------------------
Q1. What is exception handling? Mechanism to handle runtime errors.
Q2. What is an exception? An event that disrupts normal program flow.
Q3. Types: Checked (IOException), Unchecked (ArithmeticException).
Q4. Checked vs Unchecked: Checked – compile-time, Unchecked – runtime.
Q5. try, catch, finally, throw, throws: try – risky code, catch – handle, finally – always executes,
throw – raise exception, throws – declare exception.
Q6. Runtime errors: Errors that occur during execution (e.g., divide by zero).
---------------------------------------- 7. FILE HANDLING ----------------------------------------
Q1. What is file handling? Reading/writing data to a file (java.io package).
Q2. Open and close file: FileReader fr = new FileReader("a.txt"); fr.close();
Q3. Streams: Input – reads data; Output – writes data.
Q4. FileReader vs BufferedReader: FileReader reads char by char; BufferedReader reads line by
line (faster).
Q5. Read line example: BufferedReader br = new BufferedReader(new FileReader("data.txt"));
String line = br.readLine();
---------------------------------------- 8. GENERAL / SHORT QUESTIONS ----------------------------------------
Q1. Who developed Java and when? James Gosling, 1995, at Sun Microsystems.
Q2. Extension of Java file: .java
Q3. Purpose of main(): Entry point of program.
Q4. Default values: int = 0, boolean = false.
Q5. Keywords vs Identifiers: Keywords – reserved words (class, int). Identifiers – user-defined (age,
name).
Q6. Compiler vs Interpreter: Compiler translates entire code, Interpreter line by line.
Q7. Platform Independence: Bytecode runs on any OS using JVM.

You might also like