arslanaslam007 / IT_Material

Here You will find Questions Related to Programming Interview
0 stars 0 forks source link

Object Oriented Programming #2

Open arslanaslam007 opened 5 years ago

arslanaslam007 commented 5 years ago

Top Short Points

Basic https://github.com/arslanaslam007/Interview/issues/2#issuecomment-464434635 Code https://github.com/arslanaslam007/Interview/issues/2#issuecomment-464434668 Function Types https://github.com/arslanaslam007/Interview/issues/2#issuecomment-464434706 Class Types https://github.com/arslanaslam007/Interview/issues/2#issuecomment-464434735 Polymorphism https://github.com/arslanaslam007/Interview/issues/2#issuecomment-464434760 Cons and Dest https://github.com/arslanaslam007/Interview/issues/2#issuecomment-464434816 Relationsip Types https://github.com/arslanaslam007/Interview/issues/2#issuecomment-464434865 Inheritance https://github.com/arslanaslam007/Interview/issues/2#issuecomment-464434896

arslanaslam007 commented 5 years ago

Basic

What is OOP ?

Diff between Instance and Class

Four Pillar of OOP 1.Abstraction 2.Encapsulation 3.Inheritance 4.Polymorphism

Related Concepts . Data Hiding Information Hiding

arslanaslam007 commented 5 years ago

Code

Qs7: What will be the output of this ?

class A { void func() { } };

class B { void func() { } };

class C: public A, public B { };

C c; c.func(); // Which function will execute ?

arslanaslam007 commented 5 years ago

Function Types

Virtual Functions Non Virtual Functions Abstract Methods Non Abstract Methods

Access Specifiers

what is signature

can runtime behaviours be achieved by any other means than Polymorphism? operator overloading? What is the purpose of it ? What if i write a function in Parent class, and dont want it to be overrided by Child? Can I do it? If yes, how ? Can this pointer access static member of a class?

arslanaslam007 commented 5 years ago

Class Types

Abstract Class Interface Sealed Class

Static Classes

arslanaslam007 commented 5 years ago

Polymorphism

V-table Virtual destructor

Qs4: What is virtual keyword ? why we use it ?

Qs5: What are virtual pointer table ? How it works in back end ?

Qs6: What is diamond problem ? How can we remove it ?

f) Questions related to Virtual concepts... P *parent = new Child; parent->f1(); // f1 function is available both in P, and C which one called and why ? parent->f2(); // f2 function is available both in P, and C but not virtual which one called ?

Dynamic and Static Binding Late and Early Binding Down Cast and Up Cast

Real Time Examples

can runtime behaviours be achieved by any other means than Polymorphism?

What is ADHOC Polymorphsim?

How does the compiler get to know that which function is to be called during polymorphism?

can we achieve polymorphism through composition?

Overriding and overloading?

What if i write a function in Parent class, and dont want it to be overrided by Child? Can I do it? If yes, how ?

arslanaslam007 commented 5 years ago

Cons and Dest

Order of Cont and Dest Why you make contructors of a class private? copy ctor

arslanaslam007 commented 5 years ago

Relationship Types

how do we know that an object is aggregated or composed? How do we get to know whther to inherit or compose an object in our class? what is strong and weak association?

cohession and coupling? method to reduce coupling ? write code with example.

arslanaslam007 commented 5 years ago

Inheritance

c) Why in JAVA, only single class inherit ?

d) What is Diamond problem ? e) A class is Parent class having function f(), B is also some other parent class which have same function f(), C class inherit both A and B in C++ if C class method call function f(), which method will be called ? ?

    class A { void func() {} };
    class B { void func() {} };
    class C: public A, public B { void method() { func() } };