What are local interfaces? Describe.



What are local interfaces? Describe...

Answer / Priyanka Kashyap

"Local interfaces" are Java interfaces that are declared within a package-private or private scope, meaning they can only be accessed within the same package as their declaring class. Unlike regular interfaces, local interfaces cannot have static members and must be implemented by the same class that declares them. They provide a way to define interface methods without the need for a separate file.nnExample:npublic class MyClass {nprivate interface LocalInterface {nvoid myMethod();n}nnpublic void doSomething() {nnew LocalInterface() {n@Overridenvoid myMethod() {n// implementation heren}n}.myMethod();n}n}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Advanced Java Interview Questions

What is the difference between static and non-static with examples?

1 Answers   HCL,


Why use a datasource when you can directly specify a connection details? (in a J2EE application)

2 Answers  


What are different types of layout managers in java.awt package?

3 Answers   Android, CA,


JMS based on what technology?

1 Answers  


Explain the methods of Naming class, rebind( ) and lookup()?

1 Answers  


whats is mean by connectionpooling

2 Answers   SolutionNET,


What is a modular application? What does module-relative mean?

1 Answers  


What is RMI architecture?

11 Answers   Infosys,


what we can't do in jdbc but can do hibernate?

3 Answers   Cap Gemini,


What is the use of Semaphore?

3 Answers  


Explain the steps in details to load the server object dynamically?

1 Answers  


What is clustering? What are the different algorithms used for clustering?

1 Answers  


Categories