Sie sind auf Seite 1von 5

Time : 3 Hours

Maximum Marks : 100


COMPUTER APPLICATIONS
ICSE
Solutions

Self Assessment Paper


1. (a) Disadvantages of OOP:
(i) The OOP programs' design is tricky.
2
(ii) We need to do proper planning and proper design of OOP programming.
(iii) To program with OOP the programmer must have good design skills, programming skills ,
thinking in terms of objects. (Any two)
(b) An array is a collection of same kind of variables that are referenced under a common name. All
arrays consists of contiguous memory locations. The lowest address corresponds the first element
and the highest address corresponds to the last element. There are two types of array :
(iii) Single Dimensional Array
(iv) Multi Dimensional Array
Syntax to declare array: arrayname = new type [size];
(c) char – 2 bytes, int – 4 bytes.

[ICSE Marking Scheme 2017]

Examiner's Comment
Majority of candidates did not read the question properly and wrote the size of data types in terms of bits instead of bytes.

ANSWERING TIP...
Read the question carefully. Data types should be explained with thin use and correct memory size.

(d) Entities marked as public can be accessed everywhere is the program. They have the widest scope.
Whereas, Entities marked as public can be accessed within the package. It can be accessed outside
the package but through inheritance only.
(e) (i) throw
(ii) static
2. (a) A Wrapper class can be defined as a special kind of class which wraps on the value of primitive data
type and make it appear is an object. For Example: Character is wrapper class for char.
(b) A for loop allows us to efficiently write a loop that needs to execute a statements in a given range of
values. It tests the condition before entering the loop body, hence it is called entry controlled loop.
Syntax:
for(initialization; condition check; increment/decrement)
{
statement 1;
2 OSWAAL ICSE Sample Question Papers, COMPUTER APPLICATIONS, Class-X
statement 2;
:
:
statement n;
}
(c) Typecasting refers to changing an entity of one data type into another. Implicit means done by the

JVM or the tool , not the Programmer. For Example: Java will provide us default constructor implic-
itly. Even if the programmer didn't write code for constructor, he can call default constructor.
(d) (i) Function make code reusable.
(ii) Functions improve modularity and facilitate easy debugging.
(e) char ch = wd.charAt(wd.length( )-2);

3. (a) Math.pow(a,2) +Math.pow(b,2)+ Math.pow(c,2);
(b) a=26

(c) charAt returns the character at the specified index, as also specified in its name. The return type of

this function is char.
(d)

Constructor Function
Constructor can be defined as a special mem- A program module used simultaneously at
ber function(member method) of the class different instances in the program is called
which gets invoked whenever object of data method or function. In simple words, we can
is created. As soon as it invokes it initiates the say that a function is subprogram that acts on
data members with their default values. data and returns a value. Method and Func-
tion both are same thing, but being concerned
with Object Oriented Programming model the
word method is used.
The constructor initialize the value of the mem- The function do the assigned act.
ber data in the class.

(e)

Method Description
public String next() it returns the next token from the scanner.
public String nextLine() it moves the scanner position to the next line and returns the value
as a string.

(f) Identifier is a name given to a variable, constant or to entities such as variables, functions, classes

etc. Keywords are the words whose meaning is already been defined to the compiler of the lan-
guage.
(g) Depending on the type of parameters passed, max( ) can have 4 possible return types: int, long,

float, double.
(h) x[0][0] is 2 and x[1][2] is 7

(i) (i) Inheritance
(ii) Abstraction
(j) (i) 6 times
(ii) 0 to 9
Solutions 3

Section - B (60 Marks)

4. Access modifiers are also known as access specifiers; these are keywords in object-oriented languages
that set the accessibility of classes, methods, and other members. In short, we can say that the visibility/
accessibility of data depends on the access specifiers. Java has the following access specifiers:
(i) private: Entities marked as private can only be accessed by methods of the same class. Private enti-
ties can not be inherited.
(ii) protected: Entities marked as public can be accessed within the package. It can be accessed outside
the package but through inheritance only.
(iii) public: Entities marked as public can be accessed everywhere is the program. They have the wid-
est scope.
Apart from the above 3, java has 1 more kind of access modifier which is associated with the enti-
ties by default. This access is called to be as the access at package level. The default members can
be accessed within the package.
5. import java.util.Scanner;
public class SpecialNumber {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter number: ");
int number = scanner.nextInt();
int rightDigit = number % 10;
int leftDigit = number / 10;
int sumOfDigits = rightDigit + leftDigit;
int productOfDigits = rightDigit * leftDigit;
int sumOfProductAndSum = sumOfDigits + productOfDigits;
if (sumOfProductAndSum == number) {
System.out.println("Special 2-digit number");
}
else {
System.out.println("Not a Special 2-digit number");
}
}
}
6. import java.util.Scanner;
public class LongestWord {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a sentence: ");
String sentence = scanner.nextLine();
int longest = 0;
int currentWordLength = 0;
for (int i = 0; i < sentence.length(); i++) {
char ch = sentence.charAt(i);
if (ch == ' ') {
if (currentWordLength > longest) {
longest = currentWordLength;
}
4 OSWAAL ICSE Sample Question Papers, COMPUTER APPLICATIONS, Class-X
currentWordLength = 0;
}
else {
currentWordLength++;
}
}
if (currentWordLength > longest) {
longest = currentWordLength;
}
System.out.println(longest);
}
}
7. public class Area {
public double area(double a, double b, double c) {
double s = (a + b + c) / 2;
double area = Math.sqrt(s * (s - a) * (s - b) * (s - c));
return area;
}
public double area(int a, int b, int height) {
double area = 0.5 * height * (a + b);
return area;
}
public double area(double diagonal1, double diagonal2) {
double area = 0.5 * (diagonal1 * diagonal2);
return area;
}
}
8. import java.util.Scanner;
public class Traingle {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Type 1 for a triangle and type 2 for an inverted triangle: ");
int ch= scanner.nextInt();
System.out.print("Enter number of terms: ");
int n = scanner.nextInt();
if (ch == 1) {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(i + " ");
}
System.out.println();
}
}
else if (ch == 2) {
for (int i = n; i >= 1; i--) {
for (int j = 1; j <= i; j++) {
Solutions 5
System.out.print(i + " ");
} System.out.println();
}
}
}
}
9. import java.util.Scanner;
public class StudentMarks {
public static void main String args[ ])
Scanner scanner = new Scanner(System.in);
int[] rno = new int[50];
int[] subjectA = new int[50];
int[] subjectB = new int [50];
int[] subjectC = new int[50];
double[] average = new double[50];
for (int i = 0; i < 50; i++) {
System.out.print(“Enter Roll No: “);
rno[i] = scanner.nextInt();
System.out.print(“Enter marks in subject A: “);
subjectA[i] = scanner.nextInt();
System.out.print(“Enter marks in subject B: “);
subjectB[i] = scanner.nextInt();
System.out.print(“Enter marks in subject C: “);
subjectC[i] = scanner.nextInt();
average[i] = (subjectA[i] + subjectB[i] + subjectC[i]) / 3.0;
}
System.out.println(“Roll No - Average”);
for (int i = 0; i < 50; i++) {
System.out.println(rno[i] + “ - “ + average[i]);
}
System.out.println(“Students with average greater than 80”);
for (int i = 0; i < 50; i++) {
if (average[i] > 80) {
System.out.println(rno[i] + “ - “ + average[i]);
}
}
System.out.println(“Students with average less than 40”);
for (int i = 0; i < 50; i++) {
if (average[i] < 40) {
System.out.println(rno[i] + “ - “ + average[i]);
}
}
}
}
qqq