Sunteți pe pagina 1din 2

Total Marks: 15

Duration:

Answer any 10 questions from the following:

1 Hr
Marks

1. Name the primitive data type in Java that is:


(i) a 64-bit integer and is used when you need a range of values wider than those
provided by int.
(ii) a single 16-bit Unicode character whose default value is \u0000

[2]

2.

[2]

Find the errors in the given program segment and re-write the statements correctly to
assign values to an integer array.
int a = new int( 5 );
for( int i=0; i<=5; i++ ) a[i]=i;
3. ________________ takes some parameters in order to create instance of a class.
i. Parameterized constructor
ii. Implicit constructor
iii. Explicit constructor
4. What will be the output when the following code segments are executed?
String s = "1001";
int x = Integer.valueOf(s);
double y = Double.valueOf(s);
System.out.println("x=" +x);
System.out.println("y=" +y);
5. Analyze the following program segment and determine how many times the body of
loop will be executed (show the working).

[2]
[2]

[2]

x = 5; y = 50;
while(x<=y) { y=y/x; System.out.println(y); }
6. What Java Keyword do you use to define a class?

i.

Object

ii. class

iii.

new

[2]
iv.

public

7. What will be the output of the following code:


Public class Test {

[2]

Public void method() { System.out.println(method called); }

Public static void main(String[] args) { Test test = new Test(); method(); }}
i. Compile error

ii. Compile successfully

iii. method called

8. Inheritance shows the relationship between child and parent class.


i. TRUE

[2]

ii. FALSE

9. Which of the following is a definition of an object?


i.

An object is an instance of a class

ii.

An object is a realization of a class

iii.

An object is a template/blueprint for a class

10. It is desired to design an object-oriented employee record system for a company.


Each employee has a name, unique id and salary. Employees belong to different
categories and their salary is determined by their category. The functions to get Name,
getld and compute salary are required. Given the class hierarchy below, possible

[2]

[2]

locations for these functions are: i. getld is implemented in the superclass ii. getld is
implemented in the subclass iii. getName is an abstract function in the superclass iv.
getName is implemented in the superclass v. getName is implemented in the subclass
vi. getSalary is an abstract function in the superclass vii. getSalary is implemented in
the superclass viii. getSalary is implemented in the subclass

a) i,iv,vi,viii

b) i,iv,vii

c) i,iii,v,vi,viii

d) ii,v,viii

11. Common behavior can be defined in a superclass and inherited into a subclass using
the _________________ keyword.
12. Which of the following is true for access modifier?
i.

The class which has a Public Modifier can be accessed from the particular
package and also from different packages

ii.

The Class which has the default modifier cannot be accessed by all the
classes of that particular package.

iii.

The class which has private as the modifier cannot be accessed by any class
even within the package

iv.

Both a and b

[2]

S-ar putea să vă placă și