Q. What is OOP?
Ans: OOP(Object oriented programming) represent a programming methodology based on objects instead of just procedure and functions.
Q. What is polymorphism?
Ans: Polymorphism is the ability of an object to behave differently in different states.
The most common use of polymorphism in oop occurs when an object of parent class hold the reference of child class object.
Q. What is method Overloading and Overriding?
Ans: Overloading:-If a class has multiple method having same name but different in parameters list, it is known as method Overloading.
Note:There are two ways to overload the method.
1. By changing number of argument
2. By changing the data type.
Remember: Overloading is not possible by changing return type of method. it will cause compilation error.
Overriding: If child class have same method as declared in the parent class. it is known as method overriding in java.
Q. can you write return statement in finally block?
Ans: Yes, but you will get warning message at compile time.
Q. What are the difference between static polymorphism and dynamic polymorphism?
Ans: Static polymorphism is achieved by method overloading. Static polymorphism is a process in which a call to a overloaded method is resolved at compile time whereas Dynamic polymorphism is a process in which a call to an overriden method is resolved at runtime.
No comments:
Post a Comment