Interview Questions and Answers - Order By Rating Q2701. Difference between Builder and Composite ?
Ans. Builder is a creational Design Pattern whereas Composite is a structural design pattern. Composite creates Parent - Child relations between your objects while Builder is used to create group of objects of predefined types. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   design pattern   builder   composite   creational design pattern   structural design pattern Q2702. Example of Chain of Responsibility Design Pattern ?
Ans. Exception Handling Throw mechanism. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   design pattern   chain of responsibility expert Q2703. Example of Observer Design Pattern ?
Ans. Listeners. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   design pattern   listeners   observer design pattern expert Q2704. Difference between Factory and Strategy Design Pattern ? Design
Ans. Factory is a creational design pattern whereas Strategy is behavioral design pattern. Factory revolves around the creation of object at runtime whereas Strategy or Policy revolves around the decision at runtime. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   design pattern   factory   strategy   creational design pattern   behavioral design pattern Asked in 1 Companies expert Q2705. Shall we use abstract classes or Interfaces in Policy / Strategy Design Pattern ?
Ans. Strategy deals only with decision making at runtime so Interfaces should be used. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   design pattern   strategy design patterm expert Q2706. Which kind of memory is used for storing object member variables and function local variables ?
Ans. Local variables are stored in stack whereas object variables are stored in heap. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   jvm   memory management   stack memory   heap memory expert Q2707. Why do member variables have default values whereas local variables don't have any default value ? Core Java
Ans. member variable are loaded into heap, so they are initialized with default values when an instance of a class is created. In case of local variables, they are stored in stack until they are being used. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   jvm   memory management   variables   stack memory   heap memory   default values expert Recently asked in Infoview Technologies. Q2708. What is a Default Constructor ? Core Java
Ans. The no argument constructor provided by Java Compiler if no constructor is specified. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   constructor   default constructor Asked in 1 Companies Basic   frequent Try 2 Question(s) Test Q2709. Will Compiler creates a default no argument constructor if we specify only multi argument constructor ?
Ans. No, Compiler will create default constructor only if we don't specify any constructor. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   constructor   default constructor   yes-no expert   rare Try 1 Question(s) Test Q2710. Can we overload constructors ?
Ans. Yes. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   constructors   overloading   yes-no   basic interview question Q2711. What will happen if we make the constructor private ? Core Java
Ans. We can't create the objects directly by invoking new operator. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   constructor   access specifier   private Asked in 1 Companies basic Try 2 Question(s) Test Q2712. How can we create objects if we make the constructor private ? Core Java
Ans. We can do so through a static public member method or static block. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   static   constructor   static method   static block  private Asked in 1 Companies Q2713. Why Java don't use pointers ?
Ans. Pointers are vulnerable and slight carelessness in their use may result in memory problems and hence Java intrinsically manage their use. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   jvm   memory management   pointers intermediate Q2714. Can we use both "this()" and "super()" in a constructor ? Core Java
Ans. No, because both this and super should be the first statement. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops  this   super   constructor Asked in 1 Companies intermediate   rare Try 2 Question(s) Test Q2715. Do we need to import java.lang package ? Core Java
Ans. No, It is loaded by default by the JVM. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   jvm   java.lang.package   yes-no Q2716. Is it necessary that each try block to be followed by catch block ? Core Java
Ans. It should be followed by either catch or finally block. Sample Code for Retry in case of exception Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   exceptions   exception handling   try   catch   finally  Oracle OCA Test Asked in 3 Companies basic   frequent Try 1 Question(s) Test Q2717. Can finally block be used without catch ? Core Java
Ans. Yes but should follow "try" block then. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   exceptions   exception handling   try   catch   finally   yes-no Try 1 Question(s) Test Q2718. What is exception propogation ? Core Java
Ans. Passing the exception object to the calling method. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   exceptions   exception handling   throw Q2719. Difference between nested and inner classes ?
Ans. Inner class is a type of nested class.
Inner classes are non static nested classes i.e the one that are associated with the instance of outer class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   static   nested classes   inner classes   nested vs inner class basic   frequent Try 1 Question(s) Test Q2720. What is a nested interface ?
Ans. Any interface declared inside a class or an 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  java   oops   nested classes Q2721. What is an Externalizable interface ?
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 Asked in 3 Companies Q2722. Difference between serializable and externalizable interface ?
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 Q2723. What is reflection ?
Ans. It is the process of examining / modifying the behaviour of an object at runtime. Sample Code for reflection Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   reflection   reflection api   ebay   mindtree Asked in 29 Companies basic   frequent Q2724. Can we instantiate the object of derived class if parent constructor is protected ? Core Java
Ans. Yes, as protected constructor is accessible in sub class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   constructor   access specifier   protected   yes-no  private constructor Q2725. Can we declare an abstract method private ?
Ans. No Abstract methods can only be declared protected or public. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   abstract   oops   access specifier   private   yes-no intermediate   rare Q2726. What are the design considerations while making a choice between using interface and abstract class ? Core Java
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 Asked in 3 Companies Q2727. What is a config Object? Java EE
Ans. The config object is an instantiation of javax.servlet.ServletConfig and is a direct wrapper around the ServletConfig object for the generated servlet. This object allows the JSP programmer access to the Servlet or JSP engine initialization parameters such as the paths or file location. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  j2ee   servlet   jsp   servlet config   servletconfig   javax Q2728. What is a pageContext Object? Java EE
Ans. The pageContext object is an instance of a javax.servlet.jsp.PageContext object. The pageContext object is used to represent the entire JSP page. This object stores references to the request and response objects for each request. The application, config, session, and out objects are derived by accessing attributes of this object.The pageContext object also contains information about the directives issued to the JSP page, including the buffering information, the errorPageURL, and page scope. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  j2ee   servlet   jsp   pagecontext   page context Q2729. What is suspend() method used for ?
Ans. suspend() method is used to suspend the execution of a thread for a period of time. We can then restart the thread by using resume() method. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   threads   multi threading   operating system   synchronization basic   rare Usually asked only to fresh graduates. Q2730. Difference between suspend() and stop() ?
Ans. Suspend method is used to suspend thread which can be restarted by using resume() method. stop() is used to stop the thread, it cannot be restarted again. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   threads   multi threading   operating system   synchronization   suspend   stop basic   rare