Read the questions as text
ICSE Class 10 Sample Paper 1
1.Q1. Choose the correct option from the following:-
i)
Which of the following packages is automatically imported and
does not require explicit import statement?
(1 Point)
javax.swing
Java.io
Java.awt
java.lang
2.ii) Wrapping up of data and functions into a single unit is called what?
(1 Point)
polymorphism
Abstraction
Encapsulation
none of these
3.iii)
Arrange in descending order of the byte size of the following
values:-
1. ‘Z’ 2. 7.25D
3. 35
4. true
(1 Point)
4, 1, 3, 2
2, 3, 1, 4
1,2,3,4
None of the above
4.iv) "if" condition is essentially formed by using-
(1 Point)
arithmetic operators
Relational operators
Logical operators
All of the above
5.v) An exception occurs at-
(1 Point)
Run time
Compile Time
Editing time
Writing time
6.Q2.Choose the correct option from the following:-
i)
Which of the following statement executes the loop 5 times?
(1 Point)
for(i=10; i<=16; i++)
for(i=0; i<5; i++)
for(i=0; i<=5; i++)
All of the above
7.ii)
char x=’a’; int y=x; What is the value of y?
(1 Point)
65
97
‘a’
None of the above
8.iii)
What is the value of the mathematical function- Math.PI()?
(1 Point)
22/7
3.14
both of the above
None of the above
9.iv)
What is the value of the a? Given that double b= -15.6
double a = Math.rint( Math.abs(b))?
(1 Point)
16
16.0
15
None of the above
10.What will be the values of a and b after the expression is evaluated-
b*=a++ + ++b (a=5, b=10)
(1 Point)
6, 160
5, 150
6, 100
5, 160
11.Q3. Fill in the blanks with the correct option:-
i)
In a switch case structure_____ is optional.
(1 Point)
Case
Switch variable
default
witch
12.ii) The ASCII codes of lower case alphabets ranges from ____ to ____.
(1 Point)
65,90 48,54 97,122
none of the above
13.iii)The _____statement is a conditional branch statement used to select one
alternative statement out of two .
(1 Point)
Case
Switch variable
default
switch
14.iv) Bluej is a __________ based platform to execute a java program.
(1 Point)
Dos
Programming
Windows
Procedure
15. Java Virtual Machine(JVM) is a_____.
(1 Point)
compiler
Byte code
Interpreter
source code
16.Q4. State True Or False:-
i) In case, in a while loop the increment/decrement is not provided it
becomes an infinite loop?
int i=1;
while(i<=10) { s=s+i;}
(1 Point)
true false
17.ii)A function cannot be defined without parameters? (1 Point)
true false
18.iii)Multiline comments are same as documentation comments? (1 Point)
true false
19.iv)Non Primitive data types store data values with reference to addresses or locations? (1 Point)
true False
20.v)
What is the result of the expression -
15> -5 || 0 >=0 && !(5<10)
(1 Point)
true
false
21.Q5. Choose the odd one out:-
(1 Point)
i) a)< b) != c)|| d)>=
22.Choose the odd one out:-
(1 Point)
ii) Abstraction Polymorphism method modularity
23.Choose the odd one out:(1 Point)
iii) return break continue System.exit(0)
24.Choose the odd one out:-
(1 Point)
iv) a)% * / &
25.Choose the odd one out:(1 Point)
v) int long short float
26.Q6. Name the following:-
i)
Certain non-graphic characters which can’t be typed directly
from the keyboard are:-
(1 Point)
data type
Separators
operators
Escape sequences
27.ii) When a variable gets initialized at the time of execution of the program.
It is-
(1 Point)
static initialization
Initialization
Dynamic Initialization
None of the above
28. iii)Conversion of a lower data type into its higher type without user
intervention is-
(1 Point)
Coersion
implicit
both a & b
Explicit
29.iv) The process in which a method calls itself is-
(1 Point)
Recursion
Pure function
Polymorphism
loop
30.v) An intermediate code obtained after compilation is-
(1 Point)
source code
byte code
Object code
None of the above
31.
Section B
Q7. There are 5 fill ups (marked ?1?, ?2?, ?3?, ?4?, ?5?) in the program below.
Complete the fill ups given below so that the program works correctly:-
THIS QUESTION IS CONTINUED IN Q32
The program is to compute the bus fare according to the distance travelled by
a passenger. Declare a class Bus, with dist as an instance variable. The
details of the class are as follows:
Class variables : dist
: integer
amount
: double
member methods: void enter() : To enter the distance
void calc()
: To calculate the amount the passenger
has to pay
DISTANCE TRAVELLED BY PASSENGER | FARE / km
________________________________________________________
First 2 km
| ₹ 5.00/km
Next 4 km
| ₹ 6.00/km
Next 9 km
| ₹ 10.00/km
> 15 km
| ₹ 15.00/km
___________________________________________________________
void print() : To display the distance travelled by the passenger along with the
amount he/she has to pay.
void main () : To create an object for the above stated class &call the functions
in the required order.
import ____?1?_____; class Bus { int dist;
public static void enter (String args[]) {
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in)); dist=__?2?__;}
First fill up?1? should be-
(1 Point)
java.io.*
Java.util.*
Both of the above
None of the above
32.ii)
Second fill up ?2? should be:-
(1 Point)
Integer.parseint ()
distance travelled
Integer.parseInt(br.readLine())
None of these
33. public static void calc(){ if (dist< =2) amount = dist*5.0;
if (dist>2 && dist <=6 ) amount = ___?3?____;
if (dist>6 && dist <=15 ) amount =__?4?____;
if (dist>15 ) amount =__?5?____; }
public void print() { System.out.print(“distance travelled is” +dist);
System.out.print(“Amount Paid is” +?6?); }
public static void main(String args[]) throws IOException
{ Bus ob = new Bus(); ob.enter();
ob.calc();ob.print();}}
iii)
Third fill up ?3? should be:- q31 continued
(1 Point)
dist * 6.0
2* 5.0 +(dist-2)* 6.0
2* 5.0 +dist* 6.0
none of the above
34.iv)
Fourth fill up ?4?should be:-
(1 Point)
1. 2* 5.0 +4 * 6.0 +(dist-6)* 10.0
2*5.0 + 4*6.0 +6*10.0
dist * 10.0
none of these
35.v)
Fifth fill up ?5?should be:-
(1 Point)
dist * 15.0
2*5.0 + 4*6.0 +6*10.0 +15 *15.0
2* 5.0 +4 * 6.0 + 9*10.0 +(dist-15)* 15.0
None of the above
36.vi)
Sixth fill up ?6?should be:-
(1 Point)
calc()
dist
amount
None of the above
37.Q8. Design a class to overload a function compare() as follows:-
a) void compare( int, int) – to compare two integers and print the greater of
the two integers.
b) void compare( char,char) – to compare the numeric value of 2 characters
and print the characters with higher numeric value.
c) void compare(String, String) – to compare the length of the two strings and
print the longer of the two
import java .util.*;
class Overload { void compare( int a, int b){ int c =0;
if(____?1?__) { c=a; else c=b;
System.out.println(“Greater number is ”
+c); }
void compare(char a, char b){ char c =’ ‘; if(____?2?__) { c=a; else c=b;
System.out.println(“Greater Character
is ” +c); }
void compare( String a, String b){ String c =””; if(____?3?__) { c=a; else c=b; System.out.println(“String with greater
length is ” +c); } public static void main(String args[])
{ Scanner sc =new Scanner(System.in); Overload ob = new Overload();ob.compare(25, 35);
ob.compare(‘Z’, ‘X’); ob.compare(“COMPUTER”, “APPLICATIONS”);}} i) What is the value of ?1?
(1 Point)
a!=b
b>a
a>b
None of the above
38.ii)
What is the value of the?2?
(1 Point)
a>b
b>a
a!=b
none of the above
39.iii)
What is the value of the?3?
(1 Point)
a.length>b.length
a>b
a.length().compareTo(b.length())
none of the above
40.iv)What is the other name of Overloading?
(1 Point)
Abstraction
Polymorphism
Encapsulation
none of the above
41.a) What is the keyword used to create an instance of a class?
(1 Point)
class
Encapsulation
new
None of the above
42.Q9. Read the following code and answer the questions that follow:-
class asdf { private int x;
public getOutput(short a) { x=++ a + --a + ++ a; System.out.print(x); } public void func(){ getOutput(5);} // Assume main method calls functions i) Name the class in which above code may be defined? (1 Point)
asdf func getOutput() None of the above
43.ii) What value will the variable a store when the object is created:(1 Point)
0 5 6 17
44.iii) What value will the variable a store after the code gets executed:(1 Point)
0 5 6 17
45.iv) What will be the output if the above code is executed assuming that method func is called in the main:(1 Point)
0 5 6 17
46.Q10. Case Study:A class is a way to bind the data describing an entity and its associated functions together. A class is a collection of objects which contains a set of data items and related functions to operate on this data. In procedure oriented languages, the data items are left global and keep floating throughout the program. This technique creates many problems in debugging logical errors. Hence, we need to have a programming concept in which data items should remain confided within the area of its application. In general there are 2 type of functions used-in-built and user defined.
i)
What is the concept of hiding the data to the outside world
called?
(1 Point)
a) Encapsulation
Abstraction
Polymorphism
None of these
47.ii)
The keyword used to make the data inaccessible to the
functions of other classes is-
(1 Point)
Private
Protected
public
default
48.iii)
The variables used as class variables are also termed as-
(1 Point)
global variables
static variables
local variables
none of these
49.iv)
A program is divided into smaller parts, each part is called a-
(1 Point)
Function
User defined module
method
all of the above
50.v) What is the similarity between access specifiers Private and Protected-
(1 Point)
Can be inherited
Can’t be used outside the class
Can be used outside the class
d) None of these
――――――――――
ICSE Class 10 Sample Paper 2
Subject: Computer Applications Grade: X ICSE Name: __________________ Date:
WORK SHEET October - 2021
Instructions: 1. Read all the instructions carefully. 2. While answering the questions follow the prescribed limit. 3. Write the correct question number exactly as it appears on the question paper. 4. Read the answers before submitting the answer paper.
1.What will be the output of following program? public class temp { public static void main(String args[]) { int x=1; if((boolean)x==true) System.out.println("True."); else System.out.println("False.");
} }
(a) True. (b) False. (c) Error
2. What will be the output of following program? public class temp {
public static void main(String args[]) {
boolean ok=true; switch(ok) {
case true: System.out.println("true");
break; case false:
System.out.println("false"); break; default:
System.out.println("default"); break; } } }
(a) Error (b) true (c) false (d) default
3. public class temp {
public static void main(String args[]) {
int x=10; System.out.println( ((x=5)?"yes":"no") ); } }
(a) yes (b) no (c) Error
4.double x = 6.2; if(x-- >= 6.0)
System.out.print("first ");
if(--x >= 5.0) System.out.print("second ");
if(x-- >= 4.0) System.out.print("third ");
else System.out.print("fourth ");
(a) first second third (b) first second fourth (c) first fourth (d) first third
Marks: 40 Time: 45 Min
Page 1 of 4
GR 10 ICSE – Computer Applications – Work Sheet 2021-22 Property of Pupil Tree, Ballari
Subject: Computer Applications Grade: X ICSE
WORK SHEET October - 2021
5. public class temp {
public static void main(String agrs[]) {
int x=10;
switch(x) {
case 5: x+= 5; case 10: x+=10; case 15: x+=15; case 20: x+=20; } System.out.println(x); } }
(a) 55 (b) 45 (c) 20 (d) 10
6. int a = 5; a +=5; switch(a){ case 5: System.out.println("5");break; case 10: System.out.println("10");break; default: System.out.println("0");
}
} }
(A) 5
(B) 10
(C) 0 (D) Compilation Error
7. Scanner sc = new Scanner(System.in); System.out.println("Enter your name : "); name = sc.nextLine(); //assume if user enters 'cppbuzz'
switch(name.length()){
case 5: case 6: case 7: case 8: case 9: case 10: System.out.print("Length is 5-10"); break; default: System.out.print("Length not in 5-10");
} (A) Compilation Error
(B) Length is 5-10 (C) Length not in 5-10
(D) nothing is printed
8. public class Main { public static int ret(){
return 0; } public static void main(String[] args) {
int a = 0; if(ret()==0) System.out.print("Sun"); System.out.println("Moon");
} }
(A) Sun
(B) SunMoon
(C) Nothing is printed (D) Compilation Error
Page 2 of 4
GR 10 ICSE – Computer Applications – Work Sheet 2021-22 Property of Pupil Tree, Ballari
Subject: Computer Applications Grade: X ICSE
WORK SHEET October - 2021
9.
int temperature = 33;
if(temperature < 0) System.out.println("Freezing");
else if(temperature < 30) System.out.println("Pleasant");
else if(temperature < 50) System.out.println("Hot");
else System.out.println("Boiling");
(a) Compilation error
(b) Pleasant
(c) Hot Boiling
(d) Hot
10. int i = 49; if(i > 50) System.out.println("Greater than 50"); System.out.println("Great"); else System.out.println("Less than 50");
(a) Greater than 50 Great (b) Compilation error (c) Great
(d) Less than 50
11. boolean a = true, b = false;
if(a && !b) System.out.println("true");
else System.out.println("false");
(a) true
(b) false
(c) Compilation error
(d) Runtime error
12.
int a = 23, b = 30;
if(a > 20 && b > 25)
System.out.println("1");
if(a > 30 && b < 35)
System.out.println("2");
else
System.out.println("3");
(a) 2. (b) 3 (c) None of the above
13. Select all true statements from the following statements 1. There must be at least one else statement after else if statement 2. There must be at least one else statement after if statement 3. else statement must have corresponding if statement 4. Curly brackets are mandatory for if, else if and else statements
14. int a = 2 * 22 + 13 - 21;
int b = 15 * 3 + 17 - 12;
if(a > b)
System.out.println("Greater");
else
System.out.println("Less");
(a) Greater
(b) Less
(c) Compilation error
(d) Runtime error
15.Modulus operator, %, can be applied to which of these? a) Integers b) Floating – point numbers c) Both Integers and floating – point numbers d) None of the mentioned
16. a) 1 1
double var1 = 1 + 5;
double var2 = var1 / 4;
int var3 = 1 + 5;
int var4 = var3 / 4;
System.out.print(var2 + " " + var4);
b) 0 1
c) 1.5 1
d) 1.5 1.0
17. int a = 1; int b = 2; int c; int d; c = ++b; d = a++; c++; b++;
Page 3 of 4
GR 10 ICSE – Computer Applications – Work Sheet 2021-22 Property of Pupil Tree, Ballari
Subject: Computer Applications
Grade: X ICSE
++a;
(a) 3 2 4
b) 3 2 3
c) 2 3 4
System.out.println(a + " " + b + " " + c);
WORK SHEET October - 2021
d) 3 4 4
18. Literal can be of which of these data types? a) integer b) float c) boolean d) all of the mentioned
19. Which of these can not be used for a variable name in Java? a) identifier b) keyword c) identifier & keyword d) none of the mentioned
20. int a[ ] = {1,2,3,4,5}; int d[ ] = a; int sum = 0; for (int j = 0; j < 3; ++j) sum += (a[j] * d[j + 1]) + (a[j + 1] * d[j]); System.out.println(sum);
21.Which of these jump statements can skip processing the remainder of the code in its body for a particular iteration? a) break b) return c) exit d) continue
22. int sum = 0;
for (int i = 0, j = 0; i < 5 & j < 5; ++i, j = i + 1)
sum += i;
System.out.println(sum);
(a) 5
b) 6 c) 14
d) compilation error
23. int x = 2;
int y = 0;
for ( ; y < 10; ++y)
{
if (y % x == 0)
continue;
else if (y == 8)
break;
else
System.out.print(y + " ");
}
a) 1 3 5 7
b) 2 4 6 8
c) 1 3 5 7 9
d) 1 2 3 4 5 6 7 8 9
24. Which of this keyword must be used to inherit a class? a) super b) this c) extent d) extends
25) Which of the following loop executes at least once?
1. for 2.do-while
3.while
4.None of these
26 ) How many times will the following code print “Hello”?
for(int i=1; i<=5; i++);
System.out.println(“ Hello “);
1.0
2.5
3.1
4.4
27 ) What will be the output of the following code?
public static void main(String args[ ])
{
int sum = 0;
for(int i=1; i<5; i++)
sum = i ;
System.out.print( sum );
}
1.15
2.5
3.21
4.4
28) How many times will the following loop execute? public static void main(String args[ ])
Page 4 of 4
GR 10 ICSE – Computer Applications – Work Sheet 2021-22
Property of Pupil Tree, Ballari
Subject: Computer Applications
Grade: X ICSE
{
int sum = 0;
for(int i=10; i>5; i++)
sum += i;
System.out.print(sum);
}
1.5
2.15
3.0
4.Infinite loop
29 ) How many times will the following loop execute?
public static void main(String args[ ])
{
int i = 1;
while( i < 10 )
if( i++ %2 == 0)
System.out.print( i );
}
1.4 2.0
3.5
4.10
WORK SHEET October - 2021
30 ) What will be the output of the following code?
public static void main(String args[ ])
for(int i = 0; i < 5; i++)
System.out.print( (char) ('a' + i) );
1. Error 2.no output
3.01234 4.abcde
31) What will be the output of the following code?
public static void main(String args[ ])
for(int i = 0; i < 5 ; i++)
System.out.print(i++);
1.024
2.error
3.135 4.01234
32) What will be the output of the following code? public static void main(String args[ ]) { for(int a = 0, b = 3; a < 3 && b > 0; a++, b--) { System.out.print(a + " " + b + ", "); } } 1.0 3, 1 2, 2 1, 2.1 2, 1 1, 3.1 3, 2 2, 3 1,
4.Compilation error
33) What will you write inside the for loop to make the code print numbers divisible by 3 between 1
and 10 (both inclusive)?
public static void main(String args[ ])
{
for( _____________ )
{
if( i % 3 == 0 )
System.out.println(i);
}
}
1.int i = 0 ; i < 10; i++
2.int i = 1 ; i <= 10; i++
3.int i = 0 ; i <= 9; i++
4.int j = 1 ; j <= 10; j++
34) What will be the output of the following code? public static void main(String[ ] args) { for(int i = 0 ; i < 3 ; i++) System.out.println(i + " "); System.out.println(i + " "); }
1.0 0 1 1 2 2 2.0 0 1 1 2 2 3 3 3.0 1 2 3 4.error
35) What will be the output of the following code? public static void main(String args[ ])
{ for(int i = 0; i < 3; i++) for(int j = 0; j < i; j++) System.out.print(i + " " + j + ", ");
}
1. 0 0, 0 1, 0 2, 1 0, 1 1, 1 2, 2 0, 2 1, 2 2,
Page 5 of 4
GR 10 ICSE – Computer Applications – Work Sheet 2021-22
Property of Pupil Tree, Ballari
Subject: Computer Applications Grade: X ICSE
2.0 0, 0 1, 0 2, 0 3, 1 0, 1 1, 1 2, 1 3, 2 0, 2 1, 2 2, 2 3, 3.1 0, 2 0, 2 1 4.None of the above
WORK SHEET October - 2021
36 )What will be the output of the following code?
public static void main(String args[ ])
{
for (int i = 0; i < 10; i++)
int x = 10;
}
1. n o output 2.10
3.Compile time error
4.10 (10 times)
37) What will be the output of the following code?
public static void main(String args[ ])
{
while(true)
{
System.out.println("RABBIT");
break;
}
}
1.RABBIT
2.RABBIT is printed unlimited number of times.
2. No output 3.Compiler error
38) What will be the output of the following code?
public static void main(String args[ ])
{
for(int k=1, j=10; k <= 5; k++)
System.out.print(k+j);
}
1.compiler error
2.10 10 10 10 10 3. 11 12 13 14 15
4. None of the above
39) What will be the output of the following code?
public static void main(String args[ ])
{
for(int k=1, j=10; k <= 5; k++)
System.out.print( k+j%1);
}
1.compiler error
2.10 10 10 10 10 3. 11 12 13 14 15
4. 12345
40)What will be the output of the following code?
public static void main(String args[])
{
String s[ ]={"cat","dog","rat","bird"};
int j=0;
for(int i=0; i<s.length; i++)
{
System.out.print(s[i].charAt(j++));
}
}
1.cdrb
2.cotd
3.tgtd
4.dtga
41 )What will be the output of the following code?
public static void main(String args[ ])
{
String s[ ]={"lion","fish","hipo","bird"};
for(int i=0; i<s.length; i++)
System.out.print(s[i].substring(0,2));
}
1.02020202
2.lifihibi
3.lfhb
3.lifihidi
42)What will be the output of the following code?
public static void main(String args[ ])
{
String s[ ]={"a","go","sky","moon"};
for(int i=0; i<s.length; i++)
{
System.out.print( (int)Math.pow(5,s[i].length( )) );
}
}
1.525125625 2.5251256255
3.5251125625
4.251256255
Page 6 of 4
GR 10 ICSE – Computer Applications – Work Sheet 2021-22 Property of Pupil Tree, Ballari
Subject: Computer Applications Grade: X ICSE
WORK SHEET October - 2021
43)What will be the output of the following code?
for(int i=1; i<=3; i++)
for(int j=1; j<=3; j++)
System.out.print(i*j+i);
1.23446869112 2.23446866912
3.2344686912
4.2334686912
44)What will be the output of the following code? for(int i=1; i<=3; i++) for(int j=1; j<=3; j++) System.out.print(i*j%(i+j));
1.1232013113 2.123201313 3.023201313
4.123221313
45)What will be the output of the following code? for(int i=4; i<=5; i++) for(int j=3; j>=1; j--) System.out.print(i+""+j); 1.434241535251 2.43424135251 3.43424153525 4.43421535251
46)What will be the output of the following code?
for(int i=4; i<=5; i++)
for(int j=3; j>=1; j--)
System.out.print((char)('A'+i+j));
1.HGFIIHG
2.HGFHGI
3.HGFIJG
4.HGFIHG
47)What will be the output of the following code?
int i=1;
do
{
System.out.println(i++);
break;
}
while(i>2);
1.1
2.2
3.3
48)What will be the output of the following code?
int i=1;
do
{
break;
System.out.println(i++);
}
while(i>2);
1. no ouput 2.1
3.error
4.4 4.infinite loop
49)What will be the output of the following code?
int i=1;
while(i<=5)
{
if (i==4)
continue;
System.out.print(i);
i++;
}
1.23
1.123
3.infinite
50) while loop cannot be replace by for-loop.
a) true
b) false
4.error
Page 7 of 4
GR 10 ICSE – Computer Applications – Work Sheet 2021-22 Property of Pupil Tree, Ballari
Subject: Computer Applications Grade: X ICSE
WORK SHEET October - 2021
Question a Write a program in java to input a three-digit number and check whether it is a Keith Number or not. The program should implement the following function prototype : void check_Keith(int). Define the main( ) method and invoke the function accordingly. Note: A Keith Number is an integer N with ‘d’ digits with following property: If a Fibonacci-like sequence (in which each term in the sequence is the sum of the ‘d’ previous terms) is formed, with the first ‘d’ terms being the decimal digits of the number N, then N itself occurs as a term in the sequence. For example, 197 is a Keith number since it generates the sequence. 1, 9, 7, 1+9+7=17, 9+7+17=33, 7+17+33=57, 17+33+57=107, 33+57+107=197 Some Keith numbers are : 14, 19, 28, 47, 61, 75, 197, 742, 1104, 1537……
Question b One shopkeeper is selling candies to the children with a provision that if any one will return 3 empty wrappers of those candies will get 1 more candy free of cost. For example if some one purchased 15 candies and without wasting the wrappers if she/he would return the wrappers to the shopkeeper then, she/he would get (15/3) = 5 candies for 15 wrappers + (5/3) = 1 candy for 3 wrappers + (5%3+1) = 1 candy for another 3 wrappers i.e., 5+1+1 = 7 extra candies. Write a program to accept the number of candies a child wants to purchase and compute and print the extra candies she/he will get from the shopkeeper on returning the maximum number of wrappers she/he would return. Also print the number of wrappers she/he will be left with.
Page 8 of 4
GR 10 ICSE – Computer Applications – Work Sheet 2021-22 Property of Pupil Tree, Ballari
――――――――――
ICSE Class 10 Sample Paper 4
COMPUTER APPLICATIONS Maximum Marks: 50
Time allowed: One hour (inclusive of reading time) ALL QUESTIONS ARE COMPULSORY.
The marks intended for questions are given in brackets [ ]. Select the correct option for each of the following questions.
SECTION A (30 Marks) All questions are compulsory
Question 1 Choose the correct answer
[5×1]
a. Which of the following is not a Java primitive type A) byte B) float C) character D) long
b. Which of the following is not mandatory in a variable declaration? A) a semicolon B) an identifier C) an assignment D) a data type
c. Continue statement can be used A) anywhere inside the main method B) anywhere inside the class C) within instance methods D) only within looping statements
d. What is byte code in Java? A) Code generated by a Java compiler B) Code generated by a Java Virtual Machine C) Name of Java source code file D) Block of code written inside a class
e. Which variables are created when an object is created with the use of the keyword 'new' and destroyed when the object is destroyed? A) Local variables B) Instance variables C) Class Variables D) Static variables
Question 2 Fill in the blanks with the correct option
[5×1]
a. If a variable is declared final, it must include …………………. value. A) integer B) no C) initial D) float
b. When the operators have the same priority, they are evaluated from …………….. …………. in the order they appear in the expression. A) right to left B) left to right C) any of the order D) depends on the compiler
c. In Java, …………. can only test for equality, whereas ………… can evaluate any type of Boolean expression. A) switch, if B) if, switch C) if, break D) continue, if
d. By using ………………. you can force an immediate termination of a loop, bypassing the conditional expression and any remaining code in the body of the loop. A) break B) continue C) terminate D) end
e. Method overloading is one of the ways that Java supports ………… A) encapsulation B) class C) inheritance D) polymorphism
Question 3 Name the following
[5×1]
a. An interpreter that converts byte code to machine language. A) JIT B) JVM C) JVG
b. They represent non-graphic characters. A) keywords B) literals C) escape sequences
c. The process by which an object acquires the properties of another object. A) Abstraction B) Polymorphism C) Inheritance d. The name given to the character set of Java. A) UNICODE B) ASCII C) IISCODE
e. A method having the same name as the class. A) Function B) Constructor C) Method
Question 4 State True Or False
a. Methods can be overloaded with a difference only in the type of the return value. A) True B) False
b. In Java, a string is a primitive data type. A) True B) False
c. Each method in a Java class must have a unique name. A) True B) False
d. Comparisons precede logical operations in Java. A) True B) False
e. A private method is accessible from inside all classes in the same package. A) True B) False
[5×1]
Question 5 Choose the odd one
a. A) += B) %= C) == D) /=
b. A) „z‟ B) “y” C) x D) 34
c. A) true B) class C) else D) for
d. A) literal B) keyword C) identifier D) object
e. A) byte B) short C) long D) double
Question 6 Give the output of the following
a. int a=5,x=50; while(a<x) { x=x/a; } System.out.println(x);
A) 5 B) 2 C)1
[5×1] [5 × 1]
b. char c=„a‟; switch (c) { case „a‟: System.out.print(“A”); case „b‟: System.out.print(“B”); default: System.out.print(“C”); }
A) A B) AB C) ABC
c. x*=5 + --q * q++ + 10; if x=5 and q=2 before evaluation. A) 36 B) 80 C) 85
d. char grade=(mark>=90)? „A‟: (mark>=80)? „B‟ : „C‟; if mark=80. A) A B) B C) C
e.
int ctr=1;
for (int i=1 ; i<=5 ; i++)
for(int j=1 ; j<=5 ; j+=2)
++ctr;
A) 15
B) 16
C) 17
SECTION B (20 Marks)
Question 7
[5 × 1]
The following program code checks if the positive integer „N‟ is a palindrome number by returning true or false. There are some places in the code marked as ?1?, ?2?, ?3?, ?4? and ?5? which are to be replaced by a statement/expression so that the code works properly.
boolean Palindrome(int N) {
int rev = ?1? ; int num = N; while (num>0)
{ int f = ?2?; rev = ?3? + f; num /= ?4?;
} if(rev == ?5?)
return true; else
return false; } Answer the following questions: a. What is the statement or expression at ?1? A) -1 B) 0 C) 10 D) 2
b. What is the statement or expression at ?2? A) N *10 B) num/10 C) num%10 D) N%10
c. What is the statement or expression at ?3? A) num * 10 B) rev * 10 C) N * 10 D) rev
d. What is the statement or expression at ?4? A) 10 B) 100 C) 2 D) f
e. What is the statement or expression at ?5? A) 1 B) num C) N D) 10
Question 8
[5 × 1]
The following function computes the quotient and remainder of a division. There are some places in the code marked as ?1?, ?2?, ?3?, ?4? and ?5? which are to be replaced by a statement/expression so that the code works properly.
public void quotientrem() {
int dividend=13,divisor=2,quo=?1?; int rem; while(dividend>=?2?) {
dividend - = ?3?; quo=?4?; } rem=?5?; }
Answer the following questions: a. What is the statement or expression at ?1? A) 1 B) 0 C) divisor D) dividend
b. What is the statement or expression at ?2? A) 0 B) divisor C) rem D) quo
c. What is the statement or expression at ?3? A) 0 B) divisor C) 10 D) quo
d. What is the statement or expression at ?4? A) quo+1 B) divisor C) dividend D) quo*10
e. What is the statement or expression at ?5? A) 1 B) quo C) divisor D) dividend
Question 9
[5 × 1]
The following program is based on the specification given below. Fill in the blanks with appropriate java statements.
Class name Book Instance variables/data members: book_no : int type to store the book number book_title : String type to store the title of the book price : double type to store the price per copy Member Methods: calc_bill() : to calculate the total cost for N number of copies, where N is passed to the function as argument accept() : to enter the details of the book purchase() : to ask the user to input the number of copies to be purchased. It invokes calc_bill() and prints the total cost to be paid by the user. Write the main method to create an object of the class and call the above member methods. Ans. import java.util.Scanner; class ?1? { int book_no; String book_title; double price; void accept () { Scanner sc=new Scanner(System.in); System.out.println(“Enter the book no.:”); book_no=sc.nextInt(); System.out.println(“Enter the book title:”); book_title=sc.nextLine(); System.out.println(“Enter the price:”); price=?2? } void calc_bill(int n) { double tcost; tcost=?3?; System.out.println(“Total Cost:”+tcost);
} void purchase() { Scanner sc=new
… (see the PDF for the full paper)