Java Classes and Objects
Java Classes and Objects - Important Points
21. | Which keyword is used to create an object in Java? |
---|
A. new
B. create
C. make
D. object
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The new keyword is used to create an object in Java.
22. | Which of the following is not a valid identifier for a class in Java? |
---|
A. MyClass
B. myclass
C. my_class
D. myClass123
View Answer Discuss Work SpaceAnswer: option b
Explanation:
Identifiers for a class in Java should begin with a capital letter and should follow camelCase convention. Therefore, option B is not a valid identifier.
23. | Which of the following is not a member of a class in Java? |
---|
A. Variables
B. Methods
C. Constructors
D. Functions
View Answer Discuss Work SpaceAnswer: option d
Explanation:
Functions are not a member of a class in JavMethods are the equivalent of functions in Java.
24. | Which of the following is not a type of constructor in Java? |
---|
A. Default constructor
B. Parameterized constructor
C. Private constructor
D. Copy constructor
View Answer Discuss Work SpaceAnswer: option c
Explanation:
There is no constructor called private constructor in JavConstructors can be default, parameterized, or copy constructor.
25. | Which of the following is not an access specifier in Java? |
---|
A. public
B. private
C. protected
D. default
View Answer Discuss Work SpaceAnswer: option d
Explanation:
There is no access specifier called default in JavBy default, if no access specifier is used, the variable or method is accessible within the package.