1600 PMP mock questions 1400 CAPM mock questions 800 SCJP 6 mock questions 600 OCAJP 7 mock questions 590 OCPJP 7 mock questions 556 SCWCD 5 mock questions 500 OCEJWCD 6 mock questions pdfDownload (java,struts, hibernet etc)

OOPs and Design Pattern interview questions

  • What is Observer pattern ? Explain with Code Example ? view answer
  • "is-a" relationship describes inheritance relationship between objects view answer
  • has-a relationship, which is also called object composition view answer
  • The four main concepts are involved in OOP view answer
  • Example Java Code For Association & Aggregation & Composition view answer
  • What are the common things need to consider while Creating and Destroying Objects view answer
  • what is the difference between encapsulation and data hiding? explain with Code example? view answer
  • Dependency In Java view answer
  • Is Singleton class is serialized ? view answer
  • What is Singleton ? and Double-checked locking ? view answer
  • What is Factory Method pattern? view answer
  • What is Adapter pattern ? view answer
  • What is Proxy and Decorator patterns ? With Java Example ? view answer
  • Brief Introduction to OOP Concepts view answer
  • What is Abstract Factory Pattern ? With Code Example ? view answer

!!! OOPs and Design Pattern interview questions !!!

What is Abstract Factory Pattern ? With Code Example ?



abstract factory returns the factory of classes.Abstract Factory Pattern provides a way to encapsulate a group of individual factories that have a common theme.This pattern separates the details of implementation of a set of objects from its general usage. public abstract class Person(){ public void read();}
public class Student extends Person(){ public void read(){ System.out.println("Student Read");}}
public class Professor extends Person(){ public void read(){ System.out.println("Professor Read");}}
public class Librarian extends Person(){ public void read(){ System.out.println("Librarian Read");}}
// Factory Class
public class InstanceFactory{
    public Person getInstance(String code){
        if(code.equals("ST")){
            return (Person)(new Student ());
            }
            if(code.equals("PF")){
                return (Person)(new Professor ());
                } if(code.equals("LB")){
                    return (Person)(new Librarian());
                }
            }
        }
                    
                    
                    
                    In the
                    Client.java class
                    {
                    }when you need Student Object call Person st = InstanceFactory.getInstance("ST");
                    System.out.println(st.read());Print : Student Read
                    Like otherswhen you need Professor Object call Person pf = InstanceFactory.getInstance("PF");
                    System.out.println(pf.read());Print : Professor Read

Reviews and Comments


PMP, CAPM, PMI is a registered certification mark of the Project Management Institute, Inc

Copyright © www.techfaq360.com 2016


About US | Contact US | Privacy Policy | Terms and Conditions  | Website disclaimer  | Cancellation and Refund Policy  | Shipping & Delivery Policy