10. class Nav{
11. public enum Direction { NORTH, SOUTH, EAST, WEST }
12. }
13. public class Sprite{
14. // insert code here
15. }
Which code, inserted at line 14, allows the Sprite class to
compile?
a)Direction d = NORTH;
b)Nav.Direction d = NORTH;
c)Direction d = Direction.NORTH;
d)Nav.Direction d = Nav.Direction.NORTH;

Answer Posted / manikandan [ gtec,vellore ]

Answer is d)Nav.Direction d = Nav.Direction.NORTH;

explanation:

enum is specified inside a class Nav and that can b called
from other class that so v use the reference of the class
Nav.it's jus shows Encapsulation concept

Is This Answer Correct ?    8 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Variables used in a switch statement can be used with which datatypes?

517


What are the Main functions of Java?

627


Can we create an object if a class doesn't have any constructor ( not even the default provided by constructor ) ?

554


Difference between class#getinstance() and new operator ?

649


what is static import in java? Explain

555






How to split arraylist elements in java?

600


Why deletion in linkedlist is fast than arraylist?

535


Why charat is used in java?

544


Explain list interface?

520


Explain about core java?

626


Why java is a platform independent? Explain

534


Why we use methods in java?

540


What is prefix of a string?

575


What is isa relationship?

564


What is an accessor?

1053