Java Language | 10 Minute‐Test 13


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 these operators is used to allocate memory for an object?

A.
malloc
B.
alloc
C.
new
D.
give

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

Operator new dynamically allocates memory for an object and returns a reference to it. This reference is address in memory of the object allocated by new.

2.

Which method can be defined only once in a program?

A.
main method
B.
finalize method
C.
static method
D.
private method

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

main() method can be defined only once in a program. Program execution begins from the main() method by java’s run time system.

3.

Which operator is used by Java run time implementations to free the memory of an object when it is no longer needed?

A.
delete
B.
free
C.
new
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

Java handles deallocation of memory automatically, we do not need to explicitly delete an element. Garbage collection only occurs during execution of the program. When no references to the object exist, that object is assumed to be no longer needed, and the memory occupied by the object can be reclaimed.

4.

What is the process of defining a method in terms of itself, that is a method that calls itself?

A.
Polymorphism
B.
Abstraction
C.
Encapsulation
D.
Recursion

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

5.

What is the process by which we can control what parts of a program can access the members of a class?

A.
Polymorphism
B.
Abstraction
C.
Encapsulation
D.
Recursion

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

6.

Which of the following statements are incorrect?

A.
static methods can call other static methods only.
B.
static methods must only access static data.
C.
static methods can not refer to this or super in any way.
D.
when object of class is declared, each object contains its own copy of static variables.

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

All objects of class share same static variable, when object of a class are declared, all the objects share same copy of static members, no copy of static variables are made.

7.

Which of these method of String class can be used to test to strings for equality?

A.
isequal()
B.
isequals()
C.
equal()
D.
equals()

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

8.

Which of these is correct way of inheriting class A by class B?

A.
class B + class A {}
B.
class B inherits class A {}
C.
class B extends A {}
D.
class B extends class A {}

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

9.

Which of these is correct way of calling a constructor having no parameters, of superclass A by subclass B?

A.
super(void);
B.
superclass.();
C.
super.A();
D.
super();

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

10.

Which of these keywords can be used to prevent inheritance of a class?

A.
super
B.
constant
C.
Class
D.
final
Submit your test now to view the Results and Statistics with answer explanation.