o overloaded methods can have the same name but must have different parameter lists
o parameter lists are considered different if the order of the arguments are different
o a subclass method can overload a super class method
o a subclass can override methods in it's super class and change it's implementation
o it must have the same return type, name, and parameter list and can only throw exceptions of the same class/subclass as those declared in the original method
2. Can you have an overloaded function that is different only in its return value
I.e. all parameters are the same but the return value is different (look for answer in the above question)
3. How do you call a method on the parent class from the inherited class (C#, Java)
Public override void DrawWindow ( )
{
base.DrawWindow ( ); // invoke the base method
Console.WriteLine (“Writing string to the listbox: {0}",
ListBoxContents);
}
4. Can you explain Polymorphism
Polymorphism: is a feature of OOP that at run time depending upon the type of object the appropriate method is called. Method overloading is the primary way polymorphism is implemented.
5. Can you explain what inheritance is and an example of when you might use it?
Is a feature of OOP that represents the "is a" relationship between different objects (classes). Say in real life a manager is an employee. So in OOPL manger class is inherited from the employee class.
6. What is an Interface? What are the difference between an Interface and an abstract class?
An Abstract class declaration has at least one instance method that is declared abstract which will be implemented by the subclasses. An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior.
7. What is a virtual method?
When an instance method declaration includes a virtual
modifier, that method is said to be a virtual method. In a virtual method invocation, the run-time type of the instance for which that invocation takes place determines the actual method implementation to invoke.
- What do you mean by static methods:
By using the static method there is no need creating an object of that class to use that method. We can directly call that method on that class. For example, say class A has static function f (), then we can call f () function as A.f (). There is no need of creating an object of class A.
9. What are design patterns? In what ways do designs patterns help build better software?
o Design patterns help software developers to reuse successful designs and architectures. It helps them to choose design alternatives that make a system reusable and avoid alternatives that compromise reusability through proven techniques as design patterns.
10. What is Encapsulation?
-Hiding data within the class and making it available only through the methods. This technique is used to protect your class against accidental changes to fields, which might leave the class in an inconsistent state.
- a tightly encapsulated object hides all it's variables and provides public accessor methods ie the only way you can use the object is by invoking it's public methods
- What are the most common techniques for reusing functionality in object-oriented systems?
o -The two most common techniques for reusing functionality in object-oriented systems are class inheritance and object composition.
- -Class inheritance lets you define the implementation of one class in terms of another's. Reuse by sub classing is often referred to as white-box reuse.
Object composition is an alternative to class inheritance. Here, new functionality is obtained by assembling or composing objects to get more complex functionality. This is known as black-box reuse.
No comments:
Post a Comment