|
|
(38 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
| ==Some Translation== | | ==Some Translation== |
− | n! Multiplicative | + | n! Factorial |
| + | |
| ==Object-oriented programming== | | ==Object-oriented programming== |
− | ===Encapsulation===
| + | Check here [[Interview_Questions(OOP)]] |
− | restricting access to some of the object's components<br>
| + | ==C++ Interview== |
− | bundling of data with the methods<br>
| + | [[C++ interview]] |
− | public and private data and methods.<br>
| + | ==Javascript/Jquery== |
− | A benefit of encapsulation is that it can reduce system complexity, and thus increases robustness, reduce risk of conflict between components.<br>
| + | [[AJAX&Jquery]]<br> |
− | === Polymorphism === | + | [http://{{SERVERNAME}}/downloads/designpattern/ Design Pattern] |
− | In C++, that type of polymorphism is called overloading.
| + | |
− | If a class has inherited a parent class, it can redefine a method and thus each class has a method with the same name but different functionality.
| + | ==Algorithm Interview Problems== |
− | ===Inheritance=== | + | [[Algorithm Problems]]<br> |
− | Inheritance is a way to reuse code of existing objects, establish a subtype from an existing object.<br>
| + | ==Data Structure== |
− | Allow replace the implementation of an inherited method or data.<br>
| + | [[All about Binary search tree]]<br> |
− | ===Public Private Protected=== | + | [[All about Linked List]]<br> |
− | A member (either data member or member function) declared in a private section of a class can only be accessed by member functions and friends of that class<br>
| + | [[Heap & Heap Sort]]<br> |
− | A member (either data member or member function) declared in a protected section of a class can only be accessed by member functions and friends of that class, and by member functions and friends of derived classes<br>
| + | [[TRIE]]<br> |
− | A member (either data member or member function) declared in a public section of a class can be accessed by anyone<br>
| + | [[Algorithm Sorting]]<br> |
− | ===Private Inheritance===
| + | |
− | Private inheritance is like making a composition.<br>
| + | |
− | One advantage to using protected/private inheritance instead of composition is that the derived class has access to protected members in the parent class. However this is kind of a double-edged sword, as it becomes easier to misuse the class.
| + | |
− | <pre> | + | |
− | class Motherboard {};
| + | |
| | | |
− | // this makes a "has a" relationship
| + | ==Regular Expression == |
− | class Computer : private Motherboard
| + | http://www.zytrax.com/tech/web/regex.htm |
− | {
| + | |
− | };
| + | |
| | | |
− | // this makes a similar "has a" relationship
| + | ==PHP== |
− | // this approach is aka "composition"
| + | [[PHP interview]] |
− | class Computer
| + | ==Java== |
− | {
| + | [[Java interview]] |
− | private:
| + | ==Python== |
− | Motherboard mobo;
| + | [[Python interview]] |
− | };
| + | |
− | </pre>
| + | |
− | ===Virtual Functions=== | + | |
− | If the function is designated virtual in the base class then the derived class' function would be called (if it exists). If it is not virtual, the base class' function would be called.
| + | |
− | To be short, virtual functions will have lowest priority to be called.
| + | |
− | ===Virtual inheritance=== | + | |
− | To avoid ambiguous call of the same 2 levels higher base class. Declare virtual to say that the 2 levels higher base class is the same shared one.
| + | |
− | <pre>
| + | |
− | class Animal {
| + | |
− | public:
| + | |
− | virtual void eat();
| + | |
− | };
| + | |
− |
| + | |
− | // Two classes virtually inheriting Animal:
| + | |
− | class Mammal : public virtual Animal {
| + | |
− | public:
| + | |
− | virtual void breathe();
| + | |
− | };
| + | |
− |
| + | |
− | class WingedAnimal : public virtual Animal {
| + | |
− | public:
| + | |
− | virtual void flap();
| + | |
− | };
| + | |
− |
| + | |
− | // A bat is still a winged mammal
| + | |
− | class Bat : public Mammal, public WingedAnimal {
| + | |
− | };
| + | |
− | </pre>
| + | |
− | To avoid ambiguous between inherited WingedAnimal::Animal and Mammal:Animal
| + | |
− | From the code above.Animal instance is unambiguous,and we can call Bat::eat().
| + | |