CBSE_Class12_IT_Java_PYQs
CBSE_Class12_IT_Java_PYQs
A compiler translates the whole program at once, while an interpreter translates it line-by-line.
Examples: int (10), float (10.5f), char ('A'), boolean (true/false), String ("Hello").
2. Control Statements
Q4. Write a Java program to find the largest of three numbers using if-else.
if(a > b && a > c) { largest = a; } else if(b > c) { largest = b; } else { largest = c; }
Q5. Write a Java program to check whether a number is even or odd using if-else.
if-else is used for conditions; switch is used for selecting from multiple options.
3. Loops in Java
Q7. Write a Java program to print numbers from 1 to 10 using a while loop.
Q8. Write a program to print the multiplication table of a number using a for loop.
for(int i=1; i<=10; i++) { System.out.println(num + " x " + i + " = " + (num*i)); }
4. Arrays
5. Functions/Methods
int factorial(int n) { int fact = 1; for(int i=1; i<=n; i++) fact *= i; return fact; }
Two or more methods with the same name but different parameters.
CBSE Class 12 - Information Technology (Code 802)
Q15. Explain the difference between call by value and call by reference.
6. Object-Oriented Programming
class Student { int rollNo; String name; void display() { System.out.println(rollNo + " " + name); } }
7. Exception Handling