What keyword should be used in a class declaration if you do not want to instantiate a class?

Here is the question I received in a recent technical test:

Which of the following keywords is used in a class declaration if you DO NOT want to instantiate the class?

  • Null
  • invalid
  • private
  • empty

Also, what is the relevance of this in a real situation? (i.e. it is used a lot) (and static was not an option I'd expect to see).

+3
source share
3 answers

Which of the following keywords is used in a class declaration if you DO NOT want to instantiate the class?

A) null B) void C) private D) empty

Missing.

nulland voidare not valid keywords in the class declaration, is emptynot a keyword, and privatedoes not interfere with creating an instance.

Question about a trick?

Edit

, , , , - ( ).

+9

, , , "private" , , , , factory, .

+5

I would rather use instatiation instead of declaring. In this case, I would select null, which

MyClass mc=null;
0
source

All Articles