wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Contructors

Total questions: 30

Worksheet time: 12mins

Name
Class
Date
1.

What is the output of the given program?

a)

Object will be created Successfully

b)

Compile Time Error

c)

Successfully Compiled, but no output

d)

None

2.

What is the output?

a)

Sample

b)

Compile Time error

c)

Successfully comiled, but nothing will be printed

d)

None

3.

What is the output?

a)

Compile Time error

b)

Sample

c)

Nothing will be printed

d)

Run Time error

4.

What is the output?

a)

Compile Time error

b)

During object creation virtual Default constructor will be created

c)

Run Time error

d)

None

5.

What is a Constructor _________

a)

Constructor is a Special Operator

b)

Constructor is a Special keyword

c)

Constructor is a Special Method

d)

Constructor is a Special variable

6.

What is the Syntax of the Constructor?

a)

return_type Name()

{

}

b)

data_type Name()

{

}

c)

modifier Name()

{

}

d)

none

7.

When the constructor will be called/invoked?

a)

It will not invoke directly, we need to call it explicitly

b)

It will be invoked automatically during the object creation

c)

It will be invoked during the main() method execution

d)

None

8.

What is the difference between constructor & method?

a)

Constructor Name is as like as class name

Method name need not be the class name

b)

Constructor Name need not be the class name

Method name is as like as class name

c)

Constructor should not have return type

Method should have the return type

d)

Constructor should have the return type

Method should not have return type

9.

What is the output?

a)

Sample

b)

Successfully Compiled, nothing will be printed

c)

Compile Time Error

d)

Runtime Error

10.

What is the output?

a)

Sample1

Sample

b)

Sample

Sample1

c)

Compile Time error

d)

Runtime Error

11.

What is the output?

a)

Sample1

Sample

b)

Sample

Sample1

c)

Compile Time Error

d)

Nothing will be printed

12.

What is the output?

a)

Sample

Sample1

Sample2

b)

Sample1

Sample

Sample2

c)

Compile Time error

d)

Runtime Error

13.

What is the output?

a)

Sample

Sample1

b)

Sample

Sample

c)

Sample1

Sample1

d)

Compile Time Error

14.

What is the output?

a)

Sample

Sample

b)

Sample1

Sample1

c)

Compile Time Error

d)

Runtime error

15.

What is the output?

a)

Sample

b)

Sample1

c)

Compile Time Error

d)

Runtime Error

16.

What is the output?

a)

Compile Time Error

b)

Sample1

c)

Sample

d)

Nothing will be printed

17.

What is the output?

a)

Compile Time Error

b)

Sample

c)

Sample1

d)

Nothing will be printed

18.

What is the output?

a)

Sample

b)

Sample1

c)

Compile Time Error

d)

Nothing will be printed

19.

What is the output?

a)

myMethod

b)

myMethod1

c)

Compile Time Error

d)

Runtime Error

20.

What is the output?

a)

Sample

Sample1

b)

Sample1

Sample

c)

Compile Time Error

d)

Nothing will be printed

21.

What is the output?

a)

Sample

Sample1

b)

Sample1

Sample

c)

Compile Time Error

d)

Nothing will be printed

22.

what is the output?

a)

Sample

Sample1

b)

Sample1

Sample

c)

Nothing will be printed

d)

Compile Time Error

23.

What is the output?

a)

Sample1

b)

Default constructor with empty body will be called

Sample

c)

Sample

Default constructor with empty body will be called

d)

Compile Time Error

24.

Which of the following is the Deep copy in object Assignment?

a)

Use the = operator to assign one object to another object

b)

use copy constructor to assign one object values to another values

c)

creating new object by using keyword "new"

d)

All the above

25.

Which of the following is the Shallow copy/Reference copy in object Assignment?

a)

Use the = operator to assign one object to another object

b)

use copy constructor to assign one object values to another values

c)

creating new object by using keyword "new"

d)

All the above

26.

What is the output?

a)

10 20

10 20

50 60

50 60

b)

10 20

10 20

50 60

10 20

c)

10 20

10 20

10 20

50 60

d)

10 20

10 20

50 60

10 50

27.

What is the output?

a)

10 20

10 20

50 60

10 20

b)

10 20

10 20

50 60

50 60

c)

10 20

50 60

50 60

10 20

d)

10 20

50 60

50 60

50 60

28.

What is the output?

a)

Sample

Initializer

b)

Initializer

Sample

c)

Compile time error

d)

Nothing will be printed

29.

What is the output?

a)

10

20

b)

20

10

c)

Nothing will print

d)

Compile time error

30.

what is the output?

a)

Sample1

b)

Sample

Sample1

c)

Nothing will be printed

d)

Compile time error