






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







public class Main { public static void main(String[] a) { int score = 50; System.out.println("MCQ"); } }
50 MCQs Code Snippets Answer + Reason Full Syllabus
Tap the next page to jump to any section.
// attempt first, then read the answer
1 Java Basics, Tokens & Data Types (Q1 to Q6) p. 3
2 Operators, Math Library & Input (Q7 to Q12) p. 4
3 Control Statements & Loops (Q13 to Q18) p. 5
4 Classes, Objects & Encapsulation (Q19 to Q24) p. 6
5 Constructors & Methods (Q25 to Q31) p. 7
6 Library Classes & Wrapper Classes (Q32 to Q36) p. 8
7 Arrays (Q37 to Q43) p. 8
8 String Handling (Q44 to Q50) p. 9
ICSE Class 10 unit Covered in Revision of Class IX: tokens, data types, operators, input, Math library, conditions, loops Sections 1, 2 and 3
Class as the basis of computation, objects, encapsulation, access specifiers Section 4 Constructors and user-defined methods (overloading, pure and impure, pass by value) Section 5
Library classes: wrapper classes, autoboxing, Character and Integer methods Section 6 Arrays: single and double dimensional, linear and binary search, bubble and selection sort Section 7 String handling and String methods Section 8
Type Size Default Example byte 1 byte 0 byte b = 10;
short 2 bytes 0 short s = 100; int 4 bytes 0 int n = 25; long 8 bytes 0L long l = 5000L; float 4 bytes 0.0f float f = 2.5f; double 8 bytes 0.0 double d = 3.14;
char 2 bytes '\u0000' char c = 'A'; boolean true / false false boolean ok = true;
MCQ Bank by Anirban Giri
(a) comment (b) keyword (c) literal (d) operator
Ans. (a) Comments are ignored by the compiler, so they are not tokens.
2 Operators, Math Library & Input
int x = 5; x += x++ + ++x; System.out.println(x);
(a) 12 (b) 16 (c) 17 (d) 18
Ans. (c) x += e means 5 + (5 + 7): x++ gives 5 (x becomes 6), then ++x makes it 7.
System.out.println(10 + 20 + "Java" + 10 + 20);
(a) 30Java30 (b) Java (c) 1020Java1020 (d) 30Java
Ans. (d) 10 + 20 is added first; once a String appears, + concatenates: 30Java1020.
(a) 4.0 (b) 5. (c) 4 (d) 5
Ans. (d) round() rounds .5 up and returns a long, so the result is 5.
(a) 7 (b) 8 (c) 7.0 (d) 8.
Ans. (d) ceil() gives the smallest whole number not less than the value, as a double.
(a) nextLine() (b) next() (c) nextInt() (d) readLine()
Ans. (a) nextLine() reads the whole line including spaces.
(a) 6 (b) 8 (c) 8.0 (d) 9.
Ans. (c) pow() always returns a double, so the result is 8.0.
MCQ Bank by Anirban Giri
3 Control Statements & Loops
for (int i = 1; i <= 3; i++) System.out.print(i * i + " ");
(a) 1 2 3 (b) 1 4 9 (c) 2 4 6 (d) 1 8 27
Ans. (b) It prints the squares of 1, 2 and 3.
int i = 10; while (i > 0) { i -= 3; }
(a) 3 (b) 4 (c) 5 (d) 10
Ans. (b) The body runs with i = 10, 7, 4 and 1 (i then becomes -2), so 4 times.
(a) for (b) while (c) do-while (d) none of these
Ans. (c) do-while checks the condition after the body, so it runs at least once.
int n = 2; switch (n) { case 1: System.out.print("A"); case 2: System.out.print("B"); case 3: System.out.print("C"); break; default: System.out.print("D"); }
(a) BCD (b) C (c) B (d) BC
Ans. (d) There is no break after case 2, so control falls through to case 3, where break stops it.
for (int i = 1; i <= 5; i++) { if (i == 3) continue; System.out.print(i); }
(a) 1245 (b) 12345 (c) 12 (d) 45
Ans. (a) continue skips only the rest of the iteration where i is 3.
MCQ Bank by Anirban Giri
5 Constructors & Methods
(a) the method (b) the class (c) the object (d) the package
Ans. (b) The constructor name must match the class name.
(a) void (b) int (c) it has no return type (not even void) (d) String
Ans. (c) A constructor never declares a return type.
(a) constructor overriding (b) recursion (c) encapsulation (d) constructor overloading
Ans. (d) Different parameter lists make them overloaded constructors.
void change(int x) { x = x + 10; } // in main: int n = 5; change(n); System.out.println(n);
(a) 5 (b) 10 (c) 15 (d) error
Ans. (a) Primitive arguments are passed by value, so n is not changed.
(a) different class names (b) different parameter lists (c) the same parameter lists (d) different return types only
Ans. (b) The number, type or order of parameters must differ (return type alone is not enough).
(a) impure method (b) constructor (c) pure method (d) static block
Ans. (c) A pure method (accessor) only reads the object's data.
(a) a compile-time error (b) a copy constructor (c) a parameterised constructor (d) a default constructor with no parameters
Ans. (d) The compiler adds a no-argument default constructor.
MCQ Bank by Anirban Giri
6 Library Classes & Wrapper Classes
(a) Character (b) Char (c) character (d) String
Ans. (a) The wrapper for char is Character.
(a) int n = "25"; (b) int n = Integer.parseInt("25"); (c) int n = Integer.toString("25"); (d) int n = String.parseInt("25");
Ans. (b) Integer.parseInt() converts a numeric String to an int.
(a) casting (b) unboxing (c) autoboxing (d) parsing
Ans. (c) Autoboxing wraps the primitive automatically; the reverse is unboxing.
(a) true (b) error (c) 7 (d) false
Ans. (d) '7' is a digit, not a letter.
(a) the String "25" (b) the double 25. (c) the int 25 (d) an error
Ans. (a) It converts the number into a String.
7 Arrays
(a) a.length() (b) a.length (c) a.size() (d) length(a)
Ans. (b) length is a property of an array, written without brackets.
(a) garbage value (b) null (c) 0 (d) -
Ans. (c) Elements of a numeric array start as 0.
MCQ Bank by Anirban Giri
(a) 3 (b) 4 (c) 1 (d) 2
Ans. (d) The first 'n' is at index 2 (b-a-n).
(a) -2 (b) 2 (c) 0 (d) 1
Ans. (a) The first difference is at index 2: 'p' (112) - 'r' (114) = -2.
(a) equals() (b) equalsIgnoreCase() (c) compareTo() (d) ==
Ans. (b) equalsIgnoreCase() treats upper and lower case letters as equal.
String s = "Java"; s.concat(" Programming"); System.out.println(s);
(a) Java (b) Java Programming (c) Programming (d) error
Ans. (a) Strings are immutable: concat() returns a new String that was not stored.
Score Result
45 to 50 Excellent: you are board-ready
35 to 44 Very good: revise the sections where you slipped 25 to 34 Good start: re-read the notes and retry the wrong questions
Below 25 Revise the basics and try again
MCQ Bank by Anirban Giri Keep coding, and all the best for your boards! · MCQ Bank by Anirban Giri