Exam Paper Print – Computer Sir Ki Class

Exam Paper: ICSE2016 (JAVA) No. of Q.26
Q.01A 2

Define Encapsulation.

Q.01B 2

What are keywords? Give an example.

Q.01C 2

Name any two library packages.

Q.01D 2

Name the type of error (syntax, runtime or logical error) in each case given below:
(i) Math.sqrt (36-45)
(ii) int a;b;c;

Q.01E 2

If int x[] = { 4, 3, 7, 8, 9, 10 }; what are the values of p and q?
(i) p = x.length
(ii) q = x[2] + x[5] * x[1]

Q.02A 2

State the difference between == operator and equals() method.

Q.02B 2

What are the types of casting shown by the following examples:
(i) char c = (char)120;
(ii) int x = ‘t’;

Q.02C 2

Differentiate between formal parameter and actual parameter.

Q.02D 2

Write a function prototype of the following:
A function PosChar which takes a string argument and a character argument and returns an integer value.

Q.02E 2

Name any two types of access specifiers.

Q.03A 2

Give the output of the following string functions :
(i) “MISSISSIPPI”.indexOf(‘S’) + “MISSISSIPPI”.lastIndexOf(‘I’)

Q.03B 2

Give the output of the following Math functions:
(i) Math.ceil(4.2)
(ii) Math.abs(-4)

Q.03C 2

What is a parameterized constructor?

Q.03D 2

Write down java expression for :
T = square root (A2 + B2 + C2)

Q.03E 2

Rewrite the following using ternary operator :
if(x%2 == 0)
System.out.print(“EVEN”);
else
System.out.print(“ODD”);

Q.03F 2

Convert the following while loop to the corresponding for loop :

int m = 5, n = 10;
while (n>=1)
{
System.out.println(m*n);
n- -;
}

Q.03G 2

Write one difference between primitive data types and composite data types.

Q.03H 2

Analyze the given program segment and answer the following questions :
(i) Write the output of the program segment
(ii) How many times does the body of the loop gets executed?
for(int m=5; m<=20; m+=5)
{
if(m%3 == 0)
break;
else
if(m%5 == 0)
System.out.println(m);
continue;
}

Q.03I 2

Give the output of the following expression :
a+=a++ + ++a + -–a + a-– ; when a = 7

Q.03J 2

Write the return type of the following library functions :
(i) isLetterOrDigit(char)
(ii) replace(char,char)

Q.04A 15

Define a class named BookFair with the following description: [15]
Instance variables/Data members:
String Bname – stores the name of the book.
double price – stores the price of the book.
Member Methods:
(i) BookFair() – Default constructor to initialize data members.
(ii) void Input() – To input and store the name and the price of the book.
(iii) void calculate() – To calculate the price after discount. Discount is calculated based on the following criteria.
PRICE DISCOUNT
Less than or equal to Rs 1000 2% of price
More than Rs 1000 and less than or equal to Rs 3000 10% of price
More than Rs 3000 15% of price
(iv) void display() – To display the name and price of the book after discount.
Write a main method to create an object of the class and call the above member methods.

Q.05A 15

Using the switch statement, write a menu driven program for the following:
(i) To print the Floyd’s triangle
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
(ii) To display the following pattern
I
I C
I C S
I C S E
For an incorrect option, an appropriate error message should be displayed.

Q.06A 15

Special words are those words which starts and ends with the same letter.
Examples:
EXISTENCE
COMIC
WINDOW
Palindrome words are those words which read the same from left to right and vice-versa.
Example:
MALAYALAM
LEVEL
ROTATOR
CIVIC
All palindromes are special words, but all special words are not palindromes.
Write a program to accept a word check and print whether the word is a palindrome or only special word.

Q.07A 15

Design a class to overload a function SumSeries() as follows: [15]
(i) void SumSeries(int n, double x) – with one integer argument and one double argument to find and display the sum of the series given
below:
s = (x/1) – (x/2) + (x/3) – (x/4) + (x/5) … to n terms
(ii) void SumSeries() – To find and display the sum of the following series:
s = 1 + (1 X 2) + (1 X 2 X 3) + … + (1 X 2 X 3 X 4 X … 20)

Q.08A 15

Write a program to accept a number and check and display whether it is a Niven number of not. [15]
(Niven number is that number which is divisible by its sum of digits).
Example:
Consider the number 126.
Sum of its digits is 1 + 2 + 6 = 9 and 126 is divisible by 9.

Q.09A 15

Write a program to initialize the seven Wonders of the World along with their locations in two different arrays. Search for a name of the
country input by the user. If found, display the name of the country along with its Wonder, otherwise display “Sorry Not Found!” [15]
Seven wonders – CHICHEN ITZA, CHRIST THE RDEEEMER, TAJMAHAL, GREAT WALL OF CHINA, MACHU PICCHU, PETRA, COLOSSEUM
Locations – MEXICO, BRAZIL, INDIA, CHINA, PERU, JORDAN, ITALY
Example – Country Name: INDIA Output: INDIA – TAJMAHAL