Java Interview Question And Answer | Core Java Interview Question And Answare | Java Interview Question And Answer For Fresher | Set 13

1.What is a package?
 Ans: A package is a collection of classes and interfaces that provides a high-level layer of access protection and name space management.

2.What is a reflection package?
 Ans: java. lang. reflect package has the ability to analyze itself in runtime.

3.What is interface and its use?
 Ans: Interface is similar to a class which may contain method’s signature only but not bodies and it is a formal set of method and constant declarations that must be defined by the class that implements it.
        Interfaces are useful for:
           a) Declaring methods that one or more classes are expected to implement
           b) Capturing similarities between unrelated classes without forcing a class relationship.
           c) Determining an object’s programming interface without revealing the actual body of the class.

4.What is an abstract class?
 Ans: An abstract class is a class designed with implementation gaps for subclasses to fill in and is deliberately incomplete.

5.What is the difference between Integer and int?
 Ans: a) Integer is a class defined in the java. lang package, whereas int is a primitive data type defined in the Java language itself. Java does not automatically convert from one to the other.
         b) Integer can be used as an argument for a method that requires an object, whereas int can be used for calculations.

6.What is a cloneable interface and how many methods does it contain?
 Ans: It is not having any method because it is a TAGGED or MARKER interface.

7.What is the difference between abstract class and interface?
 Ans: a) All the methods declared inside an interface are abstract whereas abstract class must have at least one abstract method and others may be concrete or abstract.
          b) In abstract class, key word abstract must be used for the methods whereas interface we need not use that keyword for the methods.
          c) Abstract class must have subclasses whereas interface can’t have subclasses.

8.What is the Vector class?
 Ans: The Vector class provides the capability to implement a growable array of objects

9.What modifiers may be used with an inner class that is a member of an outer class?
 Ans: A (non-local) inner class may be declared as public, protected, private, static, final, or abstract.

10.If a method is declared as protected, where may the method be accessed?
 Ans: A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared

Previous Next


:: Click the links below for similar type Questions and answers ::

0 comments:

Post a Comment

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | coupon codes