0% found this document useful (0 votes)
9 views

Sample Booklet

This document is a sample question booklet for Grade 11 Computer Science, covering various topics such as arrays, constructors, and methods in Java. It includes multiple-choice questions, error identification, output prediction, fill-in-the-blanks, theory questions, and a programming task. The booklet is designed to assess students' understanding of fundamental programming concepts.

Uploaded by

namratavij
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)
9 views

Sample Booklet

This document is a sample question booklet for Grade 11 Computer Science, covering various topics such as arrays, constructors, and methods in Java. It includes multiple-choice questions, error identification, output prediction, fill-in-the-blanks, theory questions, and a programming task. The booklet is designed to assess students' understanding of fundamental programming concepts.

Uploaded by

namratavij
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/ 4

Introduction to Computer Science

Grade 11

Sample Question Booklet

Course Code: ICS3U Teacher: Namarta Vij

Student Name: ________________ Date: 1-28-2025

Section 1: Multiple-Choice Questions (5 Marks)

1. Which of the following is true about arrays in Java?


a) Arrays are of fixed size
b) Arrays can grow in size dynamically
c) Arrays are always multidimensional
d) None of the above

2. What is a constructor in a class?


a) A method to initialize objects
b) A static block
c) A method that returns void
d) None of the above

3. Which of these is a characteristic of objects?


a) An object must have at least one method
b) Objects are instances of classes
c) Objects are methods of a class
d) None of the above

4. Which method is used to find the size of an ArrayList?


a) size()
b) length()
c) count()
d) capacity()

5. Which of the following is the correct syntax for a method named display in Java?

a) public display void() { System.out.println("Hello"); }


b) void display() { System.out.println("Hello"); }
c) public void display() { System.out.println("Hello"); }
d) display public void() { System.out.println("Hello"); }
Section 2: Find the Error (4 Marks)

1. Find the error in the following ArrayList code:

import java.util.ArrayList;
public class Test {
public static void main(String[] args) {
ArrayList<int> list = new ArrayList<>();
list.add(10);
list.add(20);
System.out.println(list.get(0));
}
}

2. Find the error below:

public class LoopTest {


public static void main(String[] args) {
int[] arr = {1, 2, 3, 4, 5};
for (i = 0; i < arr.length; i++) {
System.out.println(arr[i]);
}
}
}

3. Find the Error Question on while (true) Loop

public class WhileLoopTest {


public static void main(String[] args) {
while (true)
System.out.println("This is an infinite loop.");
System.out.println("This will never be printed.");
}
}

4. Find the error in the following code snippet and explain why it occurs:

public class ForLoopTest {


public static void main(String[] args) {
for (int i = 0; i <= 5; i++) {
System.out.println(i);
}
System.out.println(i); // Error occurs here
}
}
Section 3: What is the Output? (4 Marks)

1. Predict the output of this code:

public class Test {


String name;

public Test(String name) {


this.name = name;
}

public static void main(String[] args) {


Test obj = new Test("John");
System.out.println(obj.name);
}
}

2. What will be the output of the following code snippet?

public class ArrayTest {


public static void main(String[] args) {
int[] arr = {10, 20, 30, 40};
arr[1] = 50;
System.out.println(arr[1]);
}
}

3. What will be the output of the following code snippet?

import java.util.ArrayList;

public class ArrayListTest {


public static void main(String[] args) {
ArrayList<Integer> list = new ArrayList<>();
list.add(10);
list.add(20);
list.add(30);
list.add(1, 15);
System.out.println(list);
}
}

4. What will be the output of the following code snippet?

import java.util.LinkedList;

public class LinkedListTest {


public static void main(String[] args) {
LinkedList<Integer> list = new LinkedList<>();
list.add(10);
list.add(20);
list.addFirst(5);
list.addLast(25);
System.out.println(list);
}
}

Section 4: Fill in the Blanks (2 Marks)

1. Complete the constructor in the following class:

public class Employee {


String name;
int id;

// Constructor here
}

2. To create an array of integers in Java with 5 elements, we can use the following declaration:

int[] arr = new ________(5);

3. To add an element at the beginning of an ArrayList in Java, you can use the _________ method.

4. To create an object of a class Person in Java, we would write:

Section 5: Theory Questions (5 Marks)

1. Explain the difference between an array and an ArrayList.


2. What is the difference between a class, an object, and a method?

Section 6: Programming Question (5 Marks)


1. Write a Java program to find the factorial of a number using a loop.
Sample Input: 5
Sample Output: 120

You might also like