Ryan International School ,Vasant Kunj
📘
Java Questions – Previous Year Pattern
(CBSE)
✅
🔹 1 Mark Questions (Very Short Answer)
1. What is a constructor in Java?
2. What is the default value of a boolean variable?
3. Expand JVM.
4. What is inheritance?
5. What is the use of final keyword?
6. What is method overloading?
7. What is the size of int in Java?
8. What is the return type of main() method?
9. Define object.
10.What is garbage collection?
✅
🔹 2 Mark Questions (Short Answer)
1. Differentiate between method overloading and method overriding.
2. What is the difference between == and equals()?
3. Explain static keyword with example.
4. What is a package in Java?
5. Write two differences between compiler and interpreter.
6. What is encapsulation? Give example.
7. What is inheritance? Name its types.
8. What is this keyword?
9. What is the difference between public and private access modifiers?
10.Explain constructor overloading.
✅
🔹 3 Mark Questions
1. Write a program to check whether a number is even or odd.
2. Write a program to find the sum of digits of a number.
3. Explain types of inheritance with diagram.
4. Write a program to print the first 10 natural numbers using loop.
5. Explain parameter passing in Java with example.
6. Write a program to find largest of three numbers.
7. Explain wrapper classes.
8. Write a program to reverse a string.
✅
🔹 4 Mark Questions (Long Answer / Programs)
1. Write a program to check whether a number is palindrome.
2. Write a program to display the factorial of a number using recursion.
3. Write a program to demonstrate method overloading.
4. Explain inheritance with example program.
5. Write a program to perform linear search in an array.
6. Write a program to count:
○ vowels
○ consonants
in a string
7. Write a program to sort an array (bubble sort).
8. Write a program to demonstrate class and object concept.
✨
Example (4 Marker Answer)
Q. Write a Java program to check palindrome number
class Palindrome {
public static void main(String args[]) {
int n = 121, rev = 0, r;
int temp = n;
while(n > 0) {
r = n % 10;
rev = rev * 10 + r;
n = n / 10;
if(temp == rev)
[Link]("Palindrome");
else
[Link]("Not Palindrome");
🎯
Exam Tips (Very Important)
● 1 mark → Definition / keyword based
● 2 mark → Difference / short explanation
● 3 mark → Logic + small program
● 4 mark → Full program + output + concept
📘
Java MCQs – 1 Mark Questions
✅
🔹 Basic Concepts
1. What is the size of int in Java?
a) 2 bytes
✅
b) 4 bytes
c) 8 bytes
d) Depends on system
2. Which of the following is not a primitive data type?
a) int
b) float
✅
c) String
d) boolean
3. What is the default value of a boolean variable?
a) true
✅
b) false
c) 0
d) null
4. Which keyword is used to create an object?
a) class
✅
b) new
c) object
d) create
5. Which method is the entry point of a Java program?
a) start()
b) run()
c) main() ✅
d) init()
✅
🔹 OOP Concepts
6. Which concept allows multiple methods with same name?
a) Inheritance
✅
b) Polymorphism
c) Encapsulation
d) Abstraction
7. Which keyword is used to inherit a class?
a) implement
✅
b) extends
c) inherit
d) super
8. Which of the following is used to hide data?
a) Inheritance
✅
b) Encapsulation
c) Polymorphism
d) Abstraction
9. Which keyword refers to current object?
✅
a) this
b) super
c) current
d) object
10.Which concept is achieved using method overriding?
a) Compile time polymorphism
✅
b) Runtime polymorphism
c) Encapsulation
d) Abstraction
✅
🔹 Java Keywords & Functions
11.Which keyword is used to stop inheritance?
a) static
✅
b) final
c) private
d) break
12.Which keyword is used to define constant?
a) static
✅
b) final
c) const
d) define
13.Which function is used to take input from user?
a) [Link]()
✅
b) [Link]()
c) input()
d) read()
14.Which package is used for Scanner class?
a) [Link]
✅
b) [Link]
c) [Link]
d) [Link]
15.What is the return type of main() method?
a) int
✅
b) void
c) float
d) String
✅
🔹 Strings & Arrays
16.Which method returns length of string?
a) size()
✅
b) length()
c) len()
d) getLength()
17.Array index starts from:
a) 1
✅
b) 0
c) -1
d) Depends
18.Which of the following is correct array declaration?
✅
a) int arr[];
b) array int arr;
c) int arr;
d) arr int[];
19.Which method compares two strings?
a) compare()
✅
b) equals()
c) match()
d) ==
20.Which loop is guaranteed to execute at least once?
a) for
b) while
✅
c) do-while
d) none
🎯
Tip for Students
● MCQs often test:
✔️
Keywords
✔️
Syntax
✔️
Output-based logic
✔️
OOP concepts
📘
Java – Find the Error (1 Mark Questions)
✅
🔹 Basic Syntax Errors
1. Identify the error:
public class Test {
public static void main(String args)
[Link]("Hello");
👉 Error: String args should be String args[] or String[] args
2. Identify the error:
int a = 10
[Link](a);
👉 Error: Missing semicolon ; after 10
3. Identify the error:
[Link]("Hello World)
👉 Error: Missing closing double quote "
✅
🔹 Data Type & Variable Errors
4. Identify the error:
int a = 10.5;
👉 Error: Cannot assign decimal to int (use double)
5. Identify the error:
int 1num = 5;
👉 Error: Variable name cannot start with a number
6. Identify the error:
int a;
[Link](a);
👉 Error: Variable a not initialized
✅
🔹 OOP & Method Errors
7. Identify the error:
class Demo {
void show() {
[Link]("Hello");
public static void main(String[] args) {
show();
👉 Error: Non-static method show() cannot be called directly from static main()
8. Identify the error:
class A {
final void display() {}
class B extends A {
void display() {}
👉 Error: Cannot override a final method
✅
🔹 Loop & Condition Errors
9. Identify the error:
for(int i=0; i<5 i++)
[Link](i);
👉 Error: Missing semicolon ; between condition and increment
10. Identify the error:
if(a = 5)
{
[Link]("Yes");
👉 Error: Assignment = used instead of comparison ==
✅
🔹 String & Array Errors
11. Identify the error:
String s = "Hello";
[Link]([Link]);
👉 Error: Should be [Link]() (method call)
12. Identify the error:
int arr[] = new int[5];
arr[5] = 10;
👉 Error: Array index out of bounds (valid index: 0–4)
🎯
Exam Tip
Most common errors asked in CBSE:
● ❌ Missing ;
● ❌ Wrong method syntax (length vs length())
● ❌ Static vs non-static confusion
● ❌ Assignment = vs comparison ==
● ❌ Array index errors
📘
Java Fill in the Blanks Questions
✅
🔹 Basic Syntax
1. The entry point of a Java program is the ______ method.
👉
Answer: main
2. The keyword used to create an object is ______.
👉
Answer: new
3. Every statement in Java ends with a ______.
👉
Answer: ;
4. The method used to print output is ______.
👉
Answer: [Link]()
✅
🔹 Data Types & Variables
5. The default value of boolean is ______.
👉
Answer: false
6. The data type used to store decimal values is ______.
👉
Answer: float / double
7. Variable names cannot start with a ______.
👉
Answer: number
✅
🔹 OOP Concepts
8. The keyword used for inheritance is ______.
👉
Answer: extends
9. The keyword that refers to current object is ______.
👉
Answer: this
10.The process of hiding data is called ______.
👉
Answer: encapsulation
✅
🔹 Strings & Arrays
11.The method used to find length of string is ______.
👉 Answer: length()
12.Array index starts from ______.
👉
Answer: 0
13.The method used to compare two strings is ______.
👉
Answer: equals()
✅
🔹 Control Statements
14.The loop that executes at least once is ______ loop.
👉
Answer: do-while
15.The keyword used for decision making is ______.
👉
Answer: if
✅
🔹 Coding-Based Fill in the Blanks
16. Complete the code:
public class Test {
public static void ______(String[] args) {
[Link]("Hello");
}
}
👉 Answer: main
17. Complete the code:
int a = 10;
if(a ______ 5) {
[Link]("Greater");
}
👉 Answer: >
18. Complete the code:
for(int i=0; i<5; i______ ) {
[Link](i);
}
👉 Answer: ++
19. Complete the code:
String s = "Java";
[Link](s.______());
👉 Answer: length
20. Complete the code:
Scanner sc = new Scanner(______);
int x = [Link]();
👉 Answer: [Link]
🎯
Exam Tip
CBSE Fill-ups usually test:
● ✔️ Syntax (main, loops, operators)
● ✔️ OOP keywords
● ✔️ String methods
● ✔️ Basic logic
If you want, I can also:
✅ Make Assertion-Reason questions (new CBSE pattern)
✅ Create a full Section A (MCQs + Fill-ups + Case Study)
✅ Provide chapter-wise fill in the blanks for revision