Java Language | 10 Minute‐Test 12


Instruction

  • Total number of questions : 10.
  • Time alloted : 10 minutes.
  • Each question carry 1 mark.
  • No Negative marks
  • DO NOT refresh the page.
  • All the best :-).

1.

Which of the following is a valid declaration of an object of class Box?

A.
Box obj = new Box();
B.
Box obj = new Box;
C.
obj = new Box();
D.
new Box obj;

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

2.

Which of the following is a method having same name as that of it’s class?

A.
finalize
B.
delete
C.
class
D.
constructor

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

A constructor is a method that initializes an object immediately upon creation. It has the same name as that of class in which it resides.

3.

Which of the following is a method having same name as that of its class?

A.
finalize
B.
delete
C.
class
D.
constructor

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

A constructor is a method that initializes an object immediately upon creation. It has the same name as that of class in which it resides.

4.

Which of these is correct about passing an argument by call-by-value process?

A.
Copy of argument is made into the formal parameter of the subroutine.
B.
Reference to original argument is passed to formal parameter of the subroutine.
C.
Copy of argument is made into the formal parameter of the subroutine and changes made on parameters of subroutine have effect on original argument.
D.
Reference to original argument is passed to formal parameter of the subroutine and changes made on parameters of subroutine have effect on original argument.

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

When we pass an argument by call-by-value a copy of argument is made into the formal parameter of the subroutine and changes made on parameters of subroutine have no effect on original argument, they remain the same.

5.

Which of these is used as default for a member of a class if no access specifier is used for it?

A.
private
B.
public
C.
public, within its own package
D.
protected

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

When we pass an argument by call-by-value a copy of argument is made into the formal parameter of the subroutine and changes made on parameters of subroutine have no effect on original argument, they remain the same.

6.

Which of these cannot be declared static?

A.
class
B.
object
C.
variable
D.
method

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

static statements are run as soon as class containing then is loaded, prior to any object declaration.

7.

Which of these keywords is used to refer to member of base class from a sub class?

A.
upper
B.
super
C.
this
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Whenever a subclass needs to refer to its immediate superclass, it can do so by use of the keyword super.

8.

A class member declared protected becomes member of subclass of which type?

A.
public member
B.
private member
C.
protected member
D.
static member

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

A class member declared protected becomes private member of subclass.

9.

Which of these keywords can be used to prevent Method overriding?

A.
static
B.
constant
C.
protected
D.
final

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

To disallow a method from being overridden, specify final as a modifier at the start of its declaration. Methods declared as final cannot be overridden.

10.

Which of these method of Object class is used to obtain class of an object at run time?

A.
get()
B.
void getclass()
C.
Class getclass()
D.
None of the mentioned
Submit your test now to view the Results and Statistics with answer explanation.