Java Programming - Java Package And Interface Questions and Answers

Related Topics:

Java Programming : Java Package And Interface

Java Package and Interface Objective Questions with Answers from Basic to advanced. What are packages? What is use of packages?
1. Which of these keywords is used to define interfaces in Java?
[A] interface
[B] Interface
[C] intf
[D] Intf

Answer: A. interface

2. Which of these can be used to fully abstract a class from its implementation?
[A] Objects
[B] Packages
[C] Interfaces
[D] None of the Mentioned.

Answer: C. Interfaces

3. Which of these keywords is used to define interfaces in Java?
[A] interface
[B] Interface
[C] intf
[D] Intf

Answer: A. interface

4. Which of these keywords is used to define interfaces in Java?
[A] interface
[B] Interface
[C] intf
[D] Intf

Answer: A. interface

5. Which of these can be used to fully abstract a class from its implementation?
[A] Objects
[B] Packages
[C] Interfaces
[D] None of the Mentioned.

Answer: C. Interfaces

6. Which of these access specifiers can be used for an interface?
[A] Public
[B] Protected
[C] private
[D] All of the mentioned

Answer: A. Public

Explanation:

Access specifier of interface is either public or no specifier. When no access specifier is used then default access specifier is used due to which interface is available only to other members of the package in which it is declared, when declared public it can be used by any code.
7. Which of these keywords is used by a class to use an interface defined previously?
[A] import
[B] Import
[C] implements
[D] Implements

Answer: C. implements

Explanation:

interface is inherited by a class using implements.
8. Which of the following is correct way of implementing an interface salary by class manager?
[A] class manager extends salary {}
[B] class manager implements salary {}
[C] class manager imports salary {}
[D] None of the mentioned.

Answer: B. class manager implements salary {}

9. Which of the following package stores all the standard java classes?
[A] lang
[B] java
[C] util
[D] java.packages

Answer: B. java

10.
Which of the following is incorrect statement about packages?
[A] Interfaces specifies what class must do but not how it does.
[B] Interfaces are specified public if they are to be accessed by any code in the program.
[C] All variables in interface are implicitly final and static.
[D] All variables are static and methods are public if interface is defined pubic

Answer: D. All variables are static and methods are public if interface is defined pubic

Explanation:

All methods and variables are implicitly public if interface is declared public.

Comments: (Your feedback is valuable to us)

Ruku 2 months ago Reply

Good.But needs more questions in package than interface


Gidraf Kungu 1 year ago Reply

good


alpesh sakhanpara 1 year ago Reply

Likemcq


;