Professional Documents
Culture Documents
Grade11 RevisionWorksheetAnswer
Grade11 RevisionWorksheetAnswer
Revision Sheet
COMPUTER SCIENCE
(Theory)
(Candidates are allowed additional 15 minutes for only reading the paper.
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]
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
1. new✓
2. public
3. class
4. main
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.
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:
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 z = x + y;
Answer:
(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.
ti
ti
ti
ti
ti
ti
ti
ti
ti
ti
Output
z = 176
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]
i + c/b;
Answer
i + c/b;
⇒ int + char / byte
⇒ int + char
⇒ int
ti
Answer : 12
a. (ABC)16= ()10
PART II – 50 MARKS
Question 3. [10]
a. (3402)8 to ( )2 [2]
Answer:
Answer:
1. (999)10 [2]
Answer
2. (165.35)10 [2]
1
0
0
0
Answer:
Converting integral part
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]
Answer:
do {
..
..
do {
} while (<condition>);
..
..
} while (<condition>);
while (<condition>) {
..
..
while (<condition>) {
..
..
(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.
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.
int m = 2;
int n = 15;
m++;
--n;
Answer:
Output
m=6
n = 14
(iv) Give two differences between: Hexa-decimal and Octal number [2]
Answer
Question 5. [10]
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:
(b) Math.log()
Answer:
It returns the natural logarithm of its argument. Both return type and argument is of double
data type.
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.
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;
SECTION – B
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:
11 km to 20 km ₹6/km
21 km to 30 km ₹5/km
Design a program to input distance travelled by the passenger. Calculate and display the
fare to be paid.
import java.util.Scanner;
int fare = 0;
if (dist <= 0)
fare = 0;
fare = 80;
Variable Description:
Question 7. [10]
Using the switch statement, write a menu driven program for the following:
import java.util.Scanner;
int ch = in.nextInt();
switch (ch) {
case 1:
int a = 1;
System.out.print(a++ + "\t");
System.out.println();
break;
case 2:
String s = "ICSE";
System.out.println();
break;
default:
System.out.println("Incorrect Choice");
Variable Description:
Question 8. [10]
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;
switch(choice) {
case 'c':
double r = in.nextDouble();
break;
case 's':
break;
case 'r':
double l = in.nextDouble();
double b = in.nextDouble();
double ra = l * b;
break;
default:
System.out.println("Wrong choice!");
Variable Description:
SECTION – C
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]
:
import java.util.Scanner;
Scanner in = new Scanner(System.in);
double v = in.nextDouble();
Variable Description:
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:
import java.util.Scanner;
System.out.println(principal);
Variable Description:
Write a program to compute and display the sum of the following series:
Answer:
import java.util.Scanner;
int n = in.nextInt();
int sum = 0;
sum += i;
prod *= i;
seriesSum += term;
System.out.println("Sum=" + seriesSum);
Variable Description: