Java - Interview Questions and Answers for 'Interface' | Search Java Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com
Share

Search Java Interview Questions


 2137 questions in repository.
 There are more than 200 unanswered questions.
Click here and help us by providing the answer.
Label / Company      Label / Company / Text

   



Interview Questions and Answers for 'Interface' - 65 question(s) found - Order By Newest

Very frequently asked in phone and walk in interviews.
  Q1. What are Marker Interfaces ? Name few Java marker interfaces ?Core Java
Anonymous
Ans. These are the interfaces which have no declared methods.Serializable and cloneable are marker interfaces.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   interfaces   marker interface   serializable   clonable     Qualtech Consultants  Computer Sciences Corporation (CSC)  Addteq  Infosys  Synechron  Amdocs  JPMorgan Chase  Qualtech Consultants  Velopsys Technologies  Amdocs  Ericsson  Oracle  Avaya  Copart  Innoplexus  Volvo Information Technology      intermediate        frequent

Try 1 Question(s) Test


Very Frequently asked. Have been asked in HCL Technologies very frequently ( based on 2 feedback ). Among first few questions in many interviews.
  Q2. Differences between abstract class and interface ?Core Java
Admin
info@buggybread.com
Ans. Abstract classes can have both abstract methods ( method declarations ) as well as concrete methods ( inherited to the derived classes ) whereas Interfaces can only have abstract methods ( method declarations ).

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   classes   abstract class   interfaces     GlobalLogic  HCL Technologies  Tata Consultancy (TCS)  Infosys  Wipro  Mindtree  CapitalOne  Accenture  IBM India  Infoview Technologies  Salesforce  AT&T  United Health Group (UHG)  Verilogue  Amazon  Expeditors  Syntel  SalesForce  Cornerstone OnDemand  Expedia  OLA  NSF International  Copper Mobile  Think Future Technologies  MorphoTrust  Global Healthcare  Prodigious  Internet Brands  SciQuest  arvato Systems  iCIMS  Ideas2IT  virtusa polaris  Vitech Systems  Cognizant (CTS)      basic        frequent


 Q3. Which of the following doesn't extend Collection interface ?

a. Set
b. List
c. Map
d. Queue
Core Java
Anonymous
Ans. Map

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   collections   collection interface


 Q4. What are the different uses of Interfaces in Java ?Core Java2016-07-20 15:14:43

Ans. 1. Regulation / Enforcement / Policy / Contract , It's primary use

2. Use as a collection of utility methods(since java 8 through default methods)

3. Collecting constants together, As Interface are lighter, it makes sense to use them instead of classes if no getters and setters required.

4. Creation of Custom Annotations

5. Special services like marker interface

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     interfaces   uses of interfaces in java     BMC Software


 Q5. If an Abstract class has only abstract methods, What's the difference between such a class and an interface ?Core Java2017-05-07 07:26:29

Ans. Such a class still can have member elements which can be inherited and hence facilitate code reuse. Moreover Abstract class can have non final static elements whereas interfaces are only allowed to have static final elements.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     abstract class   interfaces     Tata Consultancy (TCS)  Infosys      Basic


 Q6. Can we declare interface methods as private ?
Anonymous
Ans. No.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   interfaces   yes-no   private


 Q7. What is an Externalizable interface ?
Anonymous
Ans. Externalizable interface is used to write the state of an object into a byte stream in compressed format.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   serialization   externalizable interface   interface     Egen Solutions  Xpanxion  MphasiS


 Q8. Difference between serializable and externalizable interface ?
Anonymous
Ans. Serializable is a marker interface whereas externalizable is not.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   serialization   externalizable   interface   marker interface


 Q9. What are the design considerations while making a choice between using interface and abstract class ?Core Java
Anonymous
Ans. Keep it as a Abstract Class if its a "Is a" Relationsship and should do subset/all of the functionality. Keep it as Interface if its a "Should Do" relationship.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   abstract classes   interfaces   advanced     ADP  AI corporation



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q10. Can we use static method definitions in Interfaces ?Core Java
Admin
info@buggybread.com
Ans. Yes, Effective Java 8.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   java8   static interface methods   yes-no     HCL Technologies


 Q11. How is Abstraction implemented in Java ?Core Java
Admin
info@buggybread.com
Ans. Abstraction is provided in Java by following ways -

Coding to the ( Interfaces / Abstract Classes ) or contracts

By Encapsulating details within classes and exposing the minimal Door ( few public methods )

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops concepts   abstraction   interfaces   abstract class   encapsulation     Accenture  Bureau Veritas      basic        frequent


 Q12. What is the use of runnable interface if we can always create a new thread using Thread class ?Core Java
Admin
info@buggybread.com
Ans. It's a choice to be made whether to use first approach ( Thread class ) or second approach ( runnable interface ) by the programmer. The second facility has been given for cases where your class is already extending some parent class and hence cannot extend another class ( for Thread ) as Java doesn't allow multiple inheritance.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   threads   multithreading   runnable interface  concurrency


 Q13. Why do we need Thread class even in case we execute thread using runnable interface ?Core Java
Admin
info@buggybread.com
Ans. Thread class holds the definition of start method ( This is the method that starts execution of new thread and then calls run method within the scope of new thread ). Interfaces don't hold any definition and so does runnable. So it makes it necessary the usage of Thread class , whatever implementation you choose.

When your class extends the thread class, it carries the definition of start method from parent Thread class onto itself and hence new yourClass.start() helps starting a new thread and then executing run method in that new thread scope.

When you implement runnable interface , you are just making it sure to the JVM that you have implemented the required method ( run() ) which the Thread start method will look for upon executing start method.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   threads   multithreading   runnable interface   thread class


 Q14. Interface can only have ...

a. Member elements and Methods.
b. Static Variables and Static Methods.
c. Static Final Variables and Instance Method Declarations.
d. Member Elements , Instance Methods, Static variables and Static Methods.
Anonymous
Ans. Static Final Variables and Instance Method Declarations.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   interfaces


 Q15. Why can't we have diamond problem with interfaces ?Core Java2017-07-30 08:15:33

Ans. Interfaces don't have member elements and method definitions that could cause diamond problem. With Java 8, Interfaces have default method definitions. This could have created diamond problem but Java introduced a compile time check for "duplicate default methods" in case same method is derived from multiple interfaces and no definition is overridden by the class.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     diamond problem  interfaces  java 8  default methods


 Q16. Is runnable a Marker interface ?Core Java
Anonymous
Ans. No , it has run method declared.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   interfaces   marker interface   runnable   yes-no


  Q17. what is the difference between collections class vs collections interface ?Core Java
Admin
info@buggybread.com
Ans. Collections class is a utility class having static methods for doing operations on objects of classes which implement the Collection interface. For example, Collections has methods for finding the max element in a Collection.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   collections   collections class   collection interface   basic interview question     Cognizant (CTS)  HCL Technologies  Infosys  Mphasis  NTT Data  Capgemini      basic        frequent

Try 1 Question(s) Test


 Q18. Whats the purpose of marker interfaces ?
Admin
info@buggybread.com
Ans. They just tell the compiler that the objects of the classes implementing the interfaces with no defined methods need to be treated differently.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   interfaces   marker interfaces   clonable   serializable      basic        frequent


 Q19. What will happen if class implement two interface having common method?
Admin
info@buggybread.com
Ans. That would not be a problem as both are specifying the contract that implement class has to follow.
If class C implement interface A & interface B then Class C thing I need to implement print() because of interface A then again Class think I need to implement print() again because of interface B, it sees that there is already a method called test() implemented so it's satisfied.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   interfaces   multiple inheritance



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q20. What is a cloneable interface and what all methods does it contain?Core Java
Admin
info@buggybread.com
Ans. Cloneable is a declaration that the class implementing it allows cloning or bitwise copy of it's object state. It is not having any method because it is a MARKER interface.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   cloneable   marker interface     ADP


  Q21. What is Comparable Interface?Core Java
Admin
info@buggybread.com
Ans. It is used to sort collections and arrays of objects using the collections.sort() and java.utils. The objects of the class implementing the Comparable interface can be ordered.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   collections   comparable interface     innoPath  Mobisoft Infotech  BNP Paribas  Nokia  Unicon  HERE Maps  Verilogue      intermediate        frequent

Try 1 Question(s) Test


 Q22. Explain Set Interface?Core Java
Admin
info@buggybread.com
Ans. It is a collection of element which cannot contain duplicate elements. The Set interface contains only methods inherited from Collection and adds the restriction that duplicate elements are prohibited.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   collections   set interface   set


 Q23. What is Externalizable interface?Core Java
Admin
info@buggybread.com
Ans. Externalizable is an interface which contains two methods readExternal and writeExternal. These methods give you a control over the serialization mechanism.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   serialization   externalizable interface     MPhasis  Egen Solutions      intermediate        rare


 Q24. What is an enumeration?Core Java
Admin
info@buggybread.com
Ans. An enumeration is an interface containing methods for accessing the underlying data structure from which the enumeration is obtained. It allows sequential access to all the elements stored in the collection.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   enum   enumeration interface   basic interview question

Try 2 Question(s) Test


 Q25. How TreeMap orders the elements if the Key is a String ?
Admin
info@buggybread.com
Ans. As String implements Comparable, It refers to the String compareTo method to identify the order relationship among those elements.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   collections   comparable interface   treemap   compareto


 Q26. Can we add heterogeneous elements into TreeMap ?
Admin
info@buggybread.com
Ans. No, Sorted collections don't allow addition of heterogeneous elements as they are not comparable.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   collections   comparable interface   treemap


 Q27. Will it create any problem if We add elements with key as user defined object into the TreeMap ?
Admin
info@buggybread.com
Ans. It won't create any problem if the objects are comparable i.e we have that class implementing Comparable interface.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   collections   treemap   comparable interface


 Q28. Can we access Interface static method using Interface references ?
Admin
info@buggybread.com
Ans. No, only using Interface Name.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   java8   static interface methods


 Q29. Can we have default method with same name and signature in the derived Interface as the static method in base Interface and vice versa ?
Admin
info@buggybread.com
Ans. Yes , we can do that as static methods are not accessible using references and hence cannot lead to conflict. We cannot do inverse as Default methods cannot be overridden with the static methods in derived interface.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   java8   default methods   static interface methods



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q30. What is Closeable ?Core Java
Admin
info@buggybread.com
Ans. A Closeable is an interface which is a source or destination of data that can be closed.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     closeable   interfaces      intermediate        rare


Not frequently asked as it was introduced with Java 8.
 Q31. What is the @FunctionalInterface annotation ?Core Java
Admin
info@buggybread.com
Ans. This is an informative annotation that specify that the interface is a functional interface. A Function Interface has only one abstract method and many default methods. Compiler generates an error if the interface specified with the annotation doesn't abide by the specifications for functional interface.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   java8   java 8   functional interface   default methods


 Q32. Name few interfaces that extends Collection Interface ?
Admin
info@buggybread.com
Ans. http://www.buggybread.com/2015/02/java-collections-interfaces-that.html

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   collections   collection interface


 Q33. Name few classes that implement Collection interface ?
Admin
info@buggybread.com
Ans. http://www.buggybread.com/2015/02/java-collections-classes-that-implement.html

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   collections   collection interface


 Q34. Is it correct to say that Interfaces are abstract data types ?
Admin
info@buggybread.com
Ans. No.

Data Type holds data whereas Interface doesn't hold anything. Interface is a contract about how to communicate with the underlying Class.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   interface   data type


 Q35. What is the package name for CertStoreParameters class?
Anonymous
Ans. java.lang

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     interfaces   java   CertStoreParameters   include


 Q36. Which is the Parent Class of CertStoreParameters class?
Anonymous
Ans. Clonable

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     interfaces   java   CertStoreParameters   include


 Q37. Variables of an interface are intrinsically ...

a. transient
b. final
c. public
d. static
Anonymous
Ans. b,c and d i.e final , public and static

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   interface   interface variables


 Q38. Which is the Parent Class of CertStoreParameters class?
Anonymous
Ans. Clonable

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     interfaces   java   CertStoreParameters   include


 Q39. In the following code , how many methods needs to be implemented in Class B ?

public interface A{
   public void method1();
   public void method2();
   public void method3();
}

abstract class B implements A{
}
Core Java

Ans. As Class B has been declared abstract , we can either implement any of these methods and just declare rest of them abstract.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     interfaces  abstract classes  code  coding

Try 2 Question(s) Test



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



Frequently asked.
 Q40. What should a class do if its implementing an interface ?Core Java

Ans. It should either implement all interface methods or declare unimplemented methods as abstract.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     interfaces     IBM      Basic        frequent

Try 1 Question(s) Test


 Q41. What was the driving force to introduce default methods in Interfaces wef from Java 8 ?Core Java2016-07-14 14:36:49

Ans. Earlier any class implementing an interface was supposed to implement all methods declared in an interface. There was no place for optionally implementing all or subset of methods.Though we have abstract classes wherein we could have provided such a mechanism by declaring some methods as abstract while providing definition for some. But as Abstract classes have a body and are comparatively heavier than interfaces and interfaces associate closely to the concept of providing interfacing than abstract classes, Java might have though of providing optional implementation for default methods. This way same interface can be reused in variety of ways rather than making copies of an interface to suit different needs.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java 8   java8  interface default methods  default methods     Infoview Technologies  Oracle  Oracle Polska  Infosys  Tata Consultancy (TCS)  CEBS Worldwide


 Q42. Does default methods introduce multiple inheritance and the Diamond problem in Java 8 ?Core Java2016-07-20 17:16:28

Ans. Default methods results in multiple inheritance of behavior and not of state. In case we try to implement multiple interfaces with default method having same name and signature, and don't override it in implementation class, it will throw an error.

For example -

interface MyInterface {
public void default myMethod(){
}
}

interface MyInterface2 {
public void default myMethod(){
}
}

class MyClass implements MyInterface,MyInterface2 {
}

This code will compilation error "Duplicate Default Method"

if we specify the definition of myMethod() in myClass, compiler won't complain and there is no conflict and MyClass can use overridden definition. But if we don't override myMethod() in MyClass, Java would be in conflict as to what definition should be carried to MyClass and hence throws compilation error.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     default methods  java 8  multiple inheritance  diamond problem   interfaces


 Q43. Do we need to implement all interface methods if a class is implementing it ?Core Java2016-08-04 14:29:39

Ans. Yes, a Class is supposed to define all abstract methods declared in the interface. With Java 8 , Interfaces can have default methods which need not be implemented by the implementing class.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     interfaces


 Q44. Where do we generally use comparable interface ?Core Java2016-08-09 10:02:01

Ans. Implementing Comparable interface means that the elements of the class are comparable i.e the class provides the implementation of compareTo method that would help comparing the elements.

This is usually required if we are planning to sort elements of a collection, If compareTo method is not defined , the sorting class / method could never understand a way to compare its elements in order to sort them.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     comparable interface

Try 1 Question(s) Test


 Q45. Why Collection interface does not extend Cloneable interface ?Core Java2016-09-15 09:40:06

Ans. Here is the list of classes that implements Collections Interface - http://www.buggybread.com/2015/02/java-collections-classes-that-implement.html

Having Collection interface to extend Cloneable interface would mean necessarily implement clone method by all implementing classes. As not all collection classes allow duplicate elements, it makes no sense to clone elements for them.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     cloneable  collections  collection interface


 Q46. Which is the root interface of Collection classes in Java ?Core Java2016-10-12 08:26:03

Ans. java.util.Collection

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     collection interface  collections


 Q47. Can we have an inner class within Interface ?Core Java2016-10-24 11:18:24

Ans. Yes, we can define an inner class within interface.Inside the interface, the inner class is implicitly public static.

So the following is legit in Java

public interface BuggyBreadInterface {
   void doSomething();

   public class BuggyBreadClass implements BuggyBreadInterface{
      void doSomething(){
         System.out.println("Do something");
      }
   }
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     inner classes  inner class in interface  nested classes


 Q48. What is nested interface?Core Java2017-01-12 14:14:44

Ans. Interface that is declared inside the interface or class, is known as nested interface. It is static by default.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     interface  nested interface      intermediate

Try 1 Question(s) Test


 Q49. What will be the output of following code ?

Base Interface

public interface BaseInterface {
   int i = 4;
}

Derived Interfaces

public interface DerivedInterface1 extends BaseInterface{
   int i = 5;
}

public interface DerivedInterface2 extends BaseInterface{
   int i=6;
}

Implementing Class

public class Class implements DerivedInterface1,DerivedInterface2 {
   public static void main(String[] args){
      System.out.println(BaseInterface.i);
   }
}

What will be the output upon executing main and Why ?
Core Java2017-01-26 13:42:29

Ans. It will print 4 because member elements of an interface are implicitly static and hence the concept of overriding doesn't work.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     interfaces  coding  code  extending interfaces  diamond interfaces     Bank Of America      intermediate



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q50. What will be the output of following code ?

Base Interface

public interface BaseInterface {
   int i = 4;
}

Derived Interfaces

public interface DerivedInterface1 extends BaseInterface{
   int i = 5;
}

public interface DerivedInterface2 extends BaseInterface{
   int i=6;
}

Implementing Class

public class Class implements DerivedInterface1,DerivedInterface2 {
int i=10;   

public static void main(String[] args){
      System.out.println(new Class().i);
   }
}

What will be the output upon executing main and Why ?
Core Java2017-01-26 13:43:11

Ans. 10

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     interfaces  coding  code      intermediate


 Q51. How Marker interfaces works internally ?Core Java2017-02-23 10:38:31

 This question was recently asked at 'GGK Technologies'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     marker interfaces  interfaces     GGK Technologies      expert        rare


 Q52. What are the types of Executor Interfaces ?Core Java2017-03-09 11:37:29

Ans. Executor - Simple Interface that supports launching new tasks.

ExecutorService - Subinterface of Executor, which adds features that help manage the lifecycle, both of the individual tasks and of the Executor itself.

ScheduledExecutorService - Subinterface of ExecutorService, supports future and-or periodic execution of tasks.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     Executor Interfaces     ADP


 Q53. What are the core interfaces in Hibernate?Hibernate2017-03-09 11:37:41

Ans. Session,SessionFactory,Configuration,Transaction,query and Criteria

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     core interfaces of Hibernate     ADP        frequent

Try 1 Question(s) Test


 Q54. What are the core interfaces of Spring mvc ?Spring2017-03-09 13:13:56

 This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     core interfaces of Spring mvc


 Q55. Can an interface be defined inside a class just like we can have inner classes inside a class ?Core Java2017-06-23 08:13:43

Ans. Yes , we can have an interface that is part of a class.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     inner class   inner interface  nested classes


 Q56. Can an interface implements another interface ?Core Java2017-06-23 08:14:33

Ans. No. No interface provides any implementation and hence the declaration isn't viable.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     interface      basic


 Q57. What are the advantage of Abstract classes over interfaces with respect to Java 7 ? and What changed in Java 8 to help facilitate that in Java 8 ?Core Java2017-08-17 19:28:33

 This question was recently asked at 'Proofpoint'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     abstract classes  interfaces  default method     Proofpoint      expert


 Q58. Why do we use Thread Class as well as Runnable Interface for creating threads in Java ?Core Java2017-08-19 19:34:44

 This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     Threads  Thread class  runnable interface


 Q59. Write a program to show thread usage in Java by implementing runnable interface2017-08-03 12:16:07

Ans. public class MyClass {
   static class MyThreadClass implements Runnable{

      public void start() {
         Thread t = new Thread(this,"threadName");
         t.start();
      }
      
      @Override
      public void run() {
         System.out.println("Hello");
         try {
            Thread.sleep(1000);
            System.out.println("Hello Again");
         } catch (InterruptedException e) {
            e.printStackTrace();
         }
         
      }
      
   }
   
   public static void main(String[] args){
      MyThreadClass myThreadClass = new MyThreadClass();
      myThreadClass.start();
      
      MyThreadClass myThreadClass2 = new MyThreadClass();
      myThreadClass2.start();
   }
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     Threads  runnable interface


 Q60. Which method needs to be implemented if a class is implementing comparable interface ?Core Java
a. comp
b. compare
c. compareTo
d. compareEquals

Ans.c. compareTo

 Q61. If X implements Y and Y extends Z, Which of the following initialization is correct ?Core Java
a. X x = new Y();
b. X x = new Z();
c. Z z = new Y();
d. Z z = new X();

Ans.d. Z z = new X();

 Q62. If class A implements X interface, and Class B implements Y interface, and X is the parent of Y, Which of the following initialization is correct ?Core Java
a. A a = new B();
b. Y y = new A();
c. X x = new B();
d. Y y = new A();

Ans.c. X x = new B();

 Q63. Which of the following is a Marker Interface ?Core Java
a. Runnable
b. Serializable
c. Cloneable
d. Both Serializable and Cloneable

Ans.d. Both Serializable and Cloneable

 Q64. Which of following can be nested into another ?Core Java
a. class within another class
b. class within interface
c. interface within class
d. All of above

Ans.d. All of above

 Q65. Which of following is not core interface of Hibernate ?Hibernate
a. Session
b. Transaction
c. SessionFactory
d. TransactionFactory

Ans.d. TransactionFactory



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus
 

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked:
         

X Close this

X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: