You are on page 1of 21

‫ دﺑﻲ‬, ‫ﻣﺪرﺳﺔ ﺟﯿﮫ اس اس اﻟﻌﺎﻟ ِﻤﯿﺔ‬

JSS INTERNATIONAL SCHOOL, DUBAI

1st Term End Examination, 2023-2024


GRADE: XI Max Marks: 70
Duration: 2 hrs

Revision Sheet

COMPUTER SCIENCE

(Theory)

Maximum Marks: 70 Time Allowed: Three hours

(Candidates are allowed additional 15 minutes for only reading the paper.

They must NOT start writing during this time).

Answer all questions in Part I (compulsory) and six questions from Part-II, choosing two questions
from Section-A, two from Section-B and two from Section-C.

All working, including rough work, should be done on the same sheet as the The intended marks for
questions or parts of questions are given in brackets [ ].

PART I – 20 MARKS
Answer all questions.
While answering ques ons in this Part, indicate brie y your working and
reasoning,wherever required.

Ques on 1
[10]

(i) The base of a Hexadecimal number is represented by:

1. H16

2. 16 ✓

ti


ti


fl


3. 15

4. None

(ii) To express a Hexadecimal number to its Binary equivalent, each Hexadecimal digit
is expressed into:

1. 2 bits form

2. 3 bits form

3. 4 bits form ✓

4. None

(iii) Which of the following keywords is used to create an instance of a class?

1. new✓

2. public

3. class

4. main

(iv) In a Hexadecimal number system 'B' represents the digit:

1. 11 ✓

2. 12

3. 14

4. 13

(iv) The process of combining data and functions that enables them to be together as a single
entity is called

1. inheritance

2. encapsulation✓

3. classi ication

4. attributes

(v) Which of the following is a blue print that creates objects of similar types?

1. abstraction

2. encapsulation

3. class✓

4. function
(vi) What is object oriented programming? Name two object oriented programming languages.

[1]

Answer:

Object Oriented Programming is an approach in which stress is laid on data rather than functions. The
data values remain associated with the functions of a particular block of the program so as to
encourage data security.

Two object oriented programming languages are C++ and Java.

(vii) What is meant by a base class and a derived class? [1]

Answer

The class that is inherited is known as base class and the class that inherits from the base is known as
derived class.

(viii) In what way is static declaration different from dynamic declaration? [1]

Answer:

In static declaration, the initial value of the variable is provided as a literal at the time of declaration.
For example:

int mathScore = 100;

double p = 1.4142135;

char ch = 'A';

In dynamic declaration, the initial value of the variable is the result of an expression or the return
value of a method call. Dynamic declaration happens at runtime. For example:

int a = 4;

int b = Math.sqrt(a);

double x = 3.14159, y = 1.4142135;

double z = x + y;

(ix) Distinguish between Syntax error and Logical error. [1]

Answer:


Syntax Error Logical Error


Syntax Errors occur when we violate the rules of Logical Errors occur due to our mistakes in
writing the statements of the programming language. programming logic.
Program compiles and executes but doesn't
Program fails to compile and execute.
give the desired output.
Logical errors need to be found and
Syntax Errors are caught by the compiler.
corrected by people working on the
program.
Syntax errors are found at compile type whereas Logical errors are found when the program starts
executing.

(x) In what way is Data Hiding related to Data Abstrac on? [1]

Answer

Data Hiding and Data Abstrac on are complementary concepts. Data Abstrac on focuses on
the observable behaviour of an object, whereas Data hiding or Data Encapsula on focuses
upon the implementa on that gives rise to this behaviour. In other words, Data Abstrac on
cares about what something does but not how it does it. Data Encapsula on cares about
how something does what it does such that others don't have to worry about the
implementa on details. Hence, we can say that Encapsula on is a way to implement Data
Abstrac on.

Ques on 2
[10]
(i) Define the Polymorphism following with an example . [2]

Answer

(a) Polymorphism is the process of using a function for carrying multiple operations. During this
process, an object may include a function for multiple operations.

As an example, if we ask different animals to speak, they respond in their own way. Dog will bark,
duck will quack, cat will say meow and so on. So, the same action of speaking is performed in
different ways by different animals. This is the concept of Polymorphism.

(ii) Perform the following arithmetic [2]

a. Add hexa-decimal numbers (1F5C)16 and (AC2B)16



ti

ti


ti


ti

ti









ti
ti



ti




ti
ti


ti

Therefore, (1F5C)16 + (AC2B)16 = (CB87)16

b. Subtract octal number (2546)8 from (5142)8

Therefore, (5142)8 - (2546)8 = (2374)8

(iii) Answer the following: [2]

a) If int y =10 then find int z = (++y*(y++ + 5));

Output

z = 176

(b) What is meant by the Coercion?

Answer:

In a mixed mode expression, when the data type of the result gets converted
into the higher most data type available in the expression without any interven on of the user, is
known as Implicit Type conversion or Coercion.
Example:

int a = 42;

long b = 50000;

long c = a + b;

Here, a is int, b is long so the result of a + b automatically gets converted into long and assigned to
variable c which is of long type.

(iv) What are the resulting data types, if the following conversions are performed? [2]

(a) int i; float f; double d; char c; byte b;

i + c/b;

Answer

i + c/b;
⇒ int + char / byte
⇒ int + char
⇒ int










ti


(b) Predict the output

int c = (3<4)? 3*4 : 3+4;

Answer : 12

(v) Convert the following [2]

a. (ABC)16= ()10

Equivalent decimal number = 12 + 176 + 2560 = 2748

Therefore, (ABC)16 = (2748)10

PART II – 50 MARKS

Answer six questions in this part, choosing two


questions fromSection A, two from Section B and two
from Section C.
SECTION - A
Answer any two questions.

Question 3. [10]

(i) Answer the following [5]

a. (3402)8 to ( )2 [2]

Answer:

Therefore, (3402)8 = (01 10 00 01 )2

b. Subtract hexa-decimal number (A68D)16 from (D53F)16 [2]

Therefore, (D53F)16 - (A68D)16 = (2EB2)16

c. Write a Java expression for the following: [1]

Answer:

z = Math.pow(x,3) + Math.pow(y,3) - y / Math.pow(z,3)

(ii) Answer the following [5]

a. Convert the following to their binary equivalents

1. (999)10 [2]

Answer

Therefore, (999)10 = (1111100111)2

2. (165.35)10 [2]








1​
0​
0​



0​

Answer:
Converting integral part

Converting fractional part

Multipl = Resulta Carr


y nt y
0.35 x 2 = 0.7 0
0.7 x 2 = 0.4 1
0.4 x 2 = 0.8 0
0.8 x 2 = 0.6 1

Therefore, (165.35)10 = (10100101.0101)2

b. What do you understand by Token? Name different types of tokens used in


Java. [1]

Answer
A token is the smallest element of a program that is meaningful to the compiler.
The different types of tokens in Java are:
1. Identifiers

2. Literals

3. Operators

4. Separators

5. Keywords

Question 4. [10]

(i) Write down the constructs (syntax) of: [4]

(a) Nested do-while loop

(b) Nested while loop

And Explain with the help of example.

Answer:

(a) Construct of Nested do-while loop

do {

//statements of outer do-while loop

..

..

do {

//statements of inner do-while loop

} while (<condition>);

..

..

} while (<condition>);

(b) Construct of Nested while loop

while (<condition>) {

//statements of outer while loop

..

..

while (<condition>) {

//statements of inner while loop

..

..

(ii) How will you convert: A decimal number to a binary number [2]

Answer:

1. Divide a decimal number by 2 and obtain quotient and remainder. The remainder will be
the least significant bit (LSB) of the binary number.

2. Divide quotient by 2 and again obtain the next quotient and remainder.

3. Repeat the above step unless quotient becomes 0.

4. The last remainder will be the most significant bit (MSB) of the binary number.

5. Arrange all the remainders from MSB to LSB. It will be the binary equivalent of the given
decimal number.

(iii) What will be the output of the following code? [2]

int m = 2;

int n = 15;

for(int i = 1 ; i < 5 ; i++)

m++;

--n;

System.out.println(" m = " + m);

System.out.println(" n = " + n);

Answer:

Output

m=6

n = 14

(iv) Give two differences between: Hexa-decimal and Octal number [2]

Answer

Hexa-decimal Octal number


It uses 16 digits — 0 to 15. It uses 8 digits — 0 to 7.
It uses base 16. It uses base 8.

Question 5. [10]

(i) What is the purpose of using following statements in a program: [2]

(a) break statement

(b) continue statement

Answer:
(a) break statement — break statement is used when the user would like to terminate the loop
before its completion and send the control to exit the loop, if certain condition is true.
(b) continue statement — When continue statement is invoked, the control goes back to check the
condition of the loop by ignoring rest of the statements of the loop.
(ii) Explain the following functions. [2]

(a) Math.cbrt()

Answer:

It returns the cube root of its argument as a double value.

(b) Math.log()

Answer:

It returns the natural logarithm of its argument. Both return type and argument is of double
data type.

(iii) Distinguish between Math.ceil() and Math.floor(). [2]

Answer:

Math.ceil( ) Math.floor( )
Returns the smallest double value that is greater Returns the largest double value that is less than
than or equal to the argument and is equal to a or equal to the argument and is equal to a
mathematical integer mathematical integer.
double a = Math.ceil(65.5); double b = Math.floor(65.5);
In this example, a will be assigned the value of In this example, b will be assigned the value of
66.0 as it is the smallest integer greater than 65.0 as it is the largest integer smaller than 65.5.
65.5.

(iv) What is meant by an infinite loop? Give an example. [2]

Answer

A loop that repeats for infinite number of iterations is known as infinite loop or endless loop.

Consider the example given below. Since all the parameters are missing in for loop, it will repeat for
infinite number of times.

for ( ; ; )

System.out.println("Infinite Loop");

(iv) Explain the term type conversion. How is implicit conversion different from explicit
conversion?. [2]

Answer:

The process of converting one predefined type into another is called type conversion.

In an implicit conversion, the result of a mixed mode expression is obtained in the higher most data
type of the variables without any intervention by the user. For example:

int a = 10;

float b = 25.5f, c;

c = a + b;

In case of explicit type conversion, the data gets converted to a type as specified by the programmer.
For example:

int a = 10;

double b = 25.5;

float c = (float)(a + b);




SECTION – B

Answer any two questions.

Each program should be written in such a way that it clearly depicts the logic of the
problem. This can be achieved by using mnemonic names and comments in the program.
(Flowcharts and Algorithms are not required.)
The programs must be written in Java.

Question 6. [10]

An air-conditioned bus charges fare from the passengers based on the distance travelled as
per the tariff given below:

Distance Travelled Fare

Up to 10 km Fixed charge ₹80

11 km to 20 km ₹6/km

21 km to 30 km ₹5/km

31 km and above ₹4/km

Design a program to input distance travelled by the passenger. Calculate and display the
fare to be paid.

import java.util.Scanner;

public class DemoBusFare

public static void main(String args[]) {

Scanner in = new Scanner(System.in);

System.out.print("Enter distance travelled: ");

int dist = in.nextInt();

int fare = 0;

if (dist <= 0)

fare = 0;

else if (dist <= 10)

fare = 80;

else if (dist <= 20)

fare = 80 + (dist - 10) * 6;

else if (dist <= 30)

fare = 80 + 60 + (dist - 20) * 5;

else if (dist > 30)

fare = 80 + 60 + 50 + (dist - 30) * 4;

System.out.println("Fare = " + fare);

Variable Description:

Variable Data Type Use

dist int To store discount.

fare int To store fare to be paid.

Question 7. [10]

Using the switch statement, write a menu driven program for the following:

(a) To print the Floyd's triangle:


1
2 3
4 5 6
7 8 9 10
11 12 13 14 15

(b) To display the following pattern:


I
IC
ICS
ICSE

For an incorrect option, an appropriate error message should be displayed.












import java.util.Scanner;

public class Demo

public void choosePattern() {

Scanner in = new Scanner(System.in);

System.out.println("Type 1 for Floyd's triangle");

System.out.println("Type 2 for an ICSE pattern");

System.out.print("Enter your choice: ");

int ch = in.nextInt();

switch (ch) {

case 1:

int a = 1;

for (int i = 1; i <= 5; i++) {

for (int j = 1; j <= i; j++) {

System.out.print(a++ + "\t");

System.out.println();

break;

case 2:

String s = "ICSE";

for (int i = 0; i < s.length(); i++) {

for (int j = 0; j <= i; j++) {

System.out.print(s.charAt(j) + " ");

System.out.println();

break;

default:

System.out.println("Incorrect Choice");

Variable Description:

Variable Data Type Use

ch int To store choice of user.

n int To store number of terms


i int To store number of rows.
j int To store number of column.
a int To store number 1.
s String To store string s.

Question 8. [10]

Write a menu driven program to calculate:

1. Area of a circle = p*r2, where p = (22/7)

2. Area of a square = side*side

3. Area of a rectangle = length*breadth

Enter 'c' to calculate area of circle, 's' to calculate area of square and 'r' to calculate area of
rectangle.

Answer:

import java.util.Scanner;

public class Demo

public static void main(String args[])

Scanner in = new Scanner(System.in);

System.out.println("Enter c to calculate area of circle");

System.out.println("Enter s to calculate area of square");

System.out.println("Enter r to calculate area of rectangle");

System.out.print("Enter your choice: ");

char choice = in.next().charAt(0);

switch(choice) {

case 'c':

System.out.print("Enter radius of circle: ");

double r = in.nextDouble();

double ca = (22 / 7.0) * r * r;

System.out.println("Area of circle = " + ca);

break;

case 's':

System.out.print("Enter side of square: ");

double side = in.nextDouble();

double sa = side * side;

System.out.println("Area of square = " + sa);

break;

case 'r':

System.out.print("Enter length of rectangle: ");

double l = in.nextDouble();

System.out.print("Enter breadth of rectangle: ");

double b = in.nextDouble();

double ra = l * b;

System.out.println("Area of rectangle = " + ra);

break;

default:

System.out.println("Wrong choice!");

Variable Description:

Variable Data Type Use

choice char To store choice of user.

r double To store radius of circle


ca double To store Area of circle.
side double To store side of square.
sa double To store Area of square.
l double To store length of rectangle.
b double To store breadth of rectangle.
ra double To store Area of rectangle

SECTION – C

Answer any two questions.

Each program should be written in such a way that it clearly depicts the logic of the
problem stepwise. This can be achieved by using comments in the program and
mnemonic names or pseudo codesfor algorithms. The programs must be written in Java
and the algorithms must be written in general / standard form, wherever required /
specified.
(Flowcharts are not required.)

Question 9. [5]
:

The volume of a sphere is calculated by using formula:


v = (4/3)*(22/7)*r3
Write a program to calculate the radius of a sphere by taking its volume as an input.
Hint: radius = ∛(volume * (3/4) * (7/22))

import java.util.Scanner;

public class Demo

public static void main(String args[]) {











Scanner in = new Scanner(System.in);

System.out.print("Enter volume of sphere: ");

double v = in.nextDouble();

double r = Math.cbrt(v * (3 / 4.0) * (7 / 22.0));

System.out.println("Radius of sphere = " + r);

Variable Description:

Variable Data Type Use

double v int To store volume of sphere

double r int To store Radius of sphere

Question 10. [5]

A certain amount of money is invested for 3 years at the rate of 6%, 8% and 10% per
annum compounded annually. Write a program to calculate:

1. the amount after 3 years.

2. the compound interest after 3 years.

Accept certain amount of money (Principal) as an input.


Hint: A = P * (1 + (R1 / 100))T * (1 + (R2 / 100))T * (1 + (R3 / 100))T and CI = A - P

import java.util.Scanner;

public class DemoCompoundInterest

public static void main(String args[])

Scanner in = new Scanner(System.in);

System.out.print("Enter the principal: ");

double principal = in.nextDouble();

System.out.println(principal);

float r1 = 6.0f, r2 = 8.0f, r3 = 10.0f;

double amount = principal * (1 + (r1 / 100)) * (1 + (r2 / 100)) * (1 + (r3 / 100));

double ci = amount - principal;

System.out.println("Amount after 3 years: " + amount);

System.out.println("Compound Interest: " + ci);

Variable Description:

Variable Data Type Use

principal double To store principal.

amount double To store amount.

ci double To store compound interest.

Question 11. [5]

Write a program to compute and display the sum of the following series:

Answer:

import java.util.Scanner;

public class Demo

public void computeSeriesSum()

Scanner in = new Scanner(System.in);

System.out.print("Enter number of terms: ");

int n = in.nextInt();

double seriesSum = 0.0;

int sum = 0;

double prod = 1.0;

for (int i = 1; i <= n; i++) {

sum += i;

prod *= i;

double term = sum / prod;

seriesSum += term;

System.out.println("Sum=" + seriesSum);

Variable Description:

Variable Data Type Use

n int To store number of terms.

sum int To store sum of numbers.


prod double To store product of numbers.
term double To store term.
seriesSum double To store sum of series.

You might also like