Java - Online Test - Pattern -


Search Java Test Questions

 223 test questions in repository.

Java - Test Questions on 'Pattern' - 5 questions found

Which of the following is not the difference between Singleton and Static class ( Class with static members only ) ?Core Java
Only one object can be created for Singleton class whereas No objects are created for static class.
Singleton class instance is initiated using new keyword whereas static class instance is created using static method.
Singleton class can be serialized whereas Static class cannot be.
Singleton Class can participate in runtime Polymorphism whereas Static class cannot.

  java  oops  singleton  design pattern  static class

With the following code, Which is a valid way to initialize ?
public class BuggyBread {

   private String element1;

   private String element2;

   private BuggyBread(String element1, String element2){
      this.element1 = element1;
      this.element2 = element2;

   public static class Builder {
      private String element1;

      private String element2;

      Builder(BuggyBread buggybread){
         element1 = buggybread.element1;
         element2 = buggybread.element2;

      Builder withElement1(String element1){
         this.element1 = element1;
         return this;

      Builder withElement2(String element2){
         this.element2 = element2;
         return this;

      BuggyBread build(){
         BuggyBread buggybread = new BuggyBread(element1,element2);
         return buggybread;
Core Java
BuggyBread buggybread = new BuggyBread();
BuggyBread buggybread = new BuggyBread("element1","element2");
BuggyBread.Builder builder = new BuggyBread.Builder();
BuggyBread.Builder builder = new BuggyBread.Builder("element1","element2");

  builder pattern

Listeners are example of ..Design
Factory design Pattern
Abstract Factory Design Pattern
Singleton Design Pattern
Observer Design Pattern

  Design Pattern

Which of the following Design pattern has been used with Hibernate Criteria ?Hibernate

  Hibernate  Design Pattern

Which of following class types in MVC holds Business logic ?Java EE


comments powered by Disqus