Examination on Java for Class IX
Full Marks -50
1. Choose the correct answers to the questions from the given options. (Do not copy the question, write
the correct answers only.) 26 x 1=26
(i) The process of binding the data and method together as one unit is called as
(a) encapsulation
(b) inheritance
(c) polymorphism
(d) dynamic binding
(ii) The operator which acts on one operand is known as
(a) binary
(b) ternary
(c) unary
(d) relational
(iii) Which of the following keyword is used to create symbolic constants in Java?
(a) final
(b) Final
(c) Constant
(d) Const
(iv) Give the output of the following.
int x;
for (x=1; x <=3; x++);
[Link] (x);
(a) 123
(b) 1234
(c) 4
(d) 1
(v) What is the final value stored in variable x?
double x=[Link]([Link](-7.3));
(a) 7.0
(b) 8.0
(c) 6.0
(d) 9.0
(vi) The program code written in any high-level language to solve a problem is
(a) object code
(b) source code
(c) machine code
(d) bytecode
(vii) Choose the odd one:
(a) >=
(b) %
(c) /
(d) *
(viii) Parameters used in the method call statement are
(a) actual parameters
(b) informal parameters
(c) formal parameters
(d) void parameters
(ix) The keyword which indicates that the method returns no value.
(a) public
(b) static
(c) void
(d) abstract
(x) Give the output of the following statement:
[Link]("Good".concat("Day"));
(a) GoodDay
(b) Good Day
(c) Goodday
(d) goodDay
(xi) The jump statement that is used inside a switch case construct to terminate a statement
sequence.
(a) continue
(b) break
(c) return
(d) goto
(xii) Give the output of the following.
int x = 2, y = 4, z = 1;
int result = (++z) + y + (++x) + (z++);
(a) 11
(b) 12
(c) 10
(d) 9
(xiii) The ASCII code of B is
(a) 67
(b) 66
(c) 98
(d) 99
(xiv) Assertion (A) The factory of object means a factory that produces the objects.
Reason (R) Class is known as object factory, because a single class generates a lot of objects.
(a) Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of
Assertion (A).
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation of
Assertion (A).
(c) Assertion (A) is true and Reason (R) is false.
(d) Assertion (A) is false and Reason (R) is true.
(xv) Abstraction is a concept, which is used to represent essential features without including the
background details or explanations. It is essential concept of Object Oriented Programming
(OOP). What is an abstraction?
(a) Abstraction is more about ‘What’ a class can do.
(b) Abstraction is more about ‘How’ to achieve that functionality.
(c) It binds data and methods in a single unit.
(d) It implements using private access modifier.
(xvi) Assertion (A) Array is a data type which can store multiple homogenous variables.
Reason (R) Elements of array are stored in an indexed manner starting with index 0.
(a) Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of
Assertion (A).
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation of
Assertion (A).
(c) Assertion (A) is true and Reason (R) is false.
(d) Assertion (A) is false and Reason (R) is true.
(xvii) Give the output of the following code:
switch(x)
{
case 'M':
[Link]("Microsoft Teams");
break;
case 'G':
[Link]("Google Meet");
default:
[Link]("Any software");
break;
case 'W':
[Link]("Web Ex");
break;
}
When x=‘g’
(a) Google Meet
(b) Any software
(c) Google Meet Any software
(d) WebEx
(xviii) Name the type of error in the statement given below:
double x: y; z:
(a) Logical error
(b) Syntax error
(c) Runtime error
(d) No error
(xix) Name the type of error that occurs for the following statement:
[Link]([Link](24 25));
(a) Syntax error
(b) Runtime error
(c) Logical error
(d) No error
(xx) The operator which acts on two operands is known as
(a) binary
(b) ternary
(c) unary
(d) relational
(xxi) The number of bytes occupied by the constant 45 are
(a) Four bytes
(b) Two bytes
(c) Eight bytes
(d) One byte
(xxii) Multiline comments in Java start with /* and end with */.
(a) True
(b) False
(c) Depend on code
(d) Depend on type of comment
(xxiii) Method which is a part of a class rather than an instance of the class is termed as
(a) static method
(b) non-static method
(c) wrapper class
(d) string method
(xxiv) The number of bits occupied by the value ‘a’ are
(a) 1 bit
(b) 2 bits
(c) 4 bits
(d) 16 bits
(xxv) Wrapper classes are available in package.
(a) [Link]
(b) [Link]
(c) [Link]
(d) [Link]
(xxvi) The method to check if a character is an alphabet or not is
(a) isLetter(char)
(b) isAlpha(char)
(c) isUppercase(char)
(d) isLowercase(char)
2. Answer the following: 12 x 2 = 24
(i) Write corresponding Java expressions for the following mathematical expressions:
(ii) Find and correct the errors in the following program segment:
int n[]= (2.4 * 0.6 * 0.8 * 0.1) ;
fpr(int i = 0 ; i <= 5 ,i++)
[Link]("n["+i+"]=" n[i]);
(iii) What will be the output of following code?
class operator {
public static void main(String args[]) {
int a = -1 , b = -2;
int maxvalue;
[Link]("a ="+a);
[Link]("b ="+b);
[Link]("maxvalue = (a > b) ? a : b ="+((a>b)?a:b));
}
}
(iv) State the purpose and return datatype of the wrapper class methods:
(a) long valueOf(String s)
(b) long parseLong(String s)
(v) Give the output of the following program segments:
int x = 10 , y = 5 , z = 0 ;
(x>y || x=y);
[Link](z + "+"+x+"+"+y);
z = x - (-y);
(vi) Give the output of the following:
(a) [Link]("He110" + 2 + 5);
(b) [Link]("He110" + (2 + 5));
(c) [Link]("B".compareTo("A"));
(d) [Link]("Welcome".charAt(2) + "Welcome".charAt(0));
(vii) Find the output.
int a = 50;
String s1 = "MAHATMA";
String s2 = "GANDHI";
[Link](a + s1 + s2);
[Link](s1 + s2);
[Link]([Link]() + [Link]());
[Link]([Link](3) + [Link](5));
(viii) Write Java expression for:
√
(ix) Assume the following initialisations and compute the results:
int j = 2;
double x = 0.005, y = -0.2;
char c = 9;
(a) [Link](x + x + y + y)
(b) [Link](j * 2 + y)
(x) Consider the following code and state the output:
char c = 'a';
switch(c) {
case 'a':
[Link]("A");
case 'b':
[Link]("B");
default:
[Link]("C");
}
(xi) How many times will the body of the following loop be executed?
for(int i = 0 ; i <= 5 ; i = i + 2)
(xii) Write the output:
(a)char c = "COMPUTER APPLICATIONS".charAt(4);
(b)"Hello".indexOf('c');
(c) int d = 97; char c = (char)d + 10;
(d)int e = 50 / 4 * 2;