menu

Java Classes and Objects

Java Classes and Objects - Important Points


11. Which keyword is used to declare a variable constant in Java?

A. final

B. static

C. abstract

D. volatile

Discuss Work Space

Answer: option a

Explanation:

The final keyword is used to declare a variable constant in Java.

12. Which of the following is a valid declaration for a method that takes two integer arguments and returns an integer in Java?

A. public int myMethod(int x, int y) {}

B. public myMethod(int x, int y) {}

C. public int myMethod(int x; int y) {}

D. public int myMethod(int x int y) {}

Discuss Work Space

Answer: option a

Explanation:

The correct syntax for a method that takes two integer arguments and returns an integer is: public int myMethod(int x, int y) {}

13. Which of the following is a valid way to declare a class variable in Java?

A. public int myVar;

B. private static myVar;

C. final double MY_VAR = 3.14;

D. public String myVar = "Hello";

Discuss Work Space

Answer: option b

Explanation:

The correct syntax to declare a class variable in Java is: access_modifier static data_type variable_name;

14. Which keyword is used to prevent a method from being overridden in a subclass in Java?

A. final

B. static

C. abstract

D. synchronized

Discuss Work Space

Answer: option a

Explanation:

The final keyword is used to prevent a method from being overridden in a subclass in Java.

15. Which of the following is not a type of access modifier in Java?

A. public

B. private

C. protected

D. package

Discuss Work Space

Answer: option d

Explanation:

There is no access modifier called package in JavAccess modifiers are public, private, and protected.


Subscribe for Latest Career Trends
Subscribe Now
Use AI and ChatGPT for Career Guidance

Unlock Your Future

Join Now
Worried for Placements in 2024?

Join FAST TRACK Course

Join Now
Supercharge Your SUCCESS

Join All in One Placement Mock Tests-2024

Join Now