Preview

Electronics Engineering

Better Essays
Open Document
Open Document
3340 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Electronics Engineering
-------------------------------------------------
OBJECT ORIENTED PROGRAMMING
Q.What is the difference between Constructor and Function or Method?
Constructor will be automatically invoked when an object is created whereas method has to be called explicitly. Constructor needs to have the same name as that of the class whereas functions need not be the same. * There is no return type given in a constructor signature (header). The value is this object itself so there is no need to indicate a return value. * There is no return statement in the body of the constructor. * The first line of a constructor must either be a call on another constructor in the same class (using this), or a call on the superclass constructor (using super). If the first line is neither of these, the compiler automatically inserts a call to the parameterless super class constructor.

Q. Define an abstract class
An abstract class is a class that is declared by using the abstract keyword. It may or may not have abstract methods. Abstract classes cannot be instantiated, but they can be extended into sub-classes.
Points of abstract class : 1. Abstract class contains abstract methods. 2. Program can't instantiate an abstract class. 3. Abstract classes contain mixture of non-abstract and abstract methods. 4. If any class contains abstract methods then it must implements all the abstract methods of the abstract class.
Simple class: A "simple" class is a class that an instance can be created from (via new operator)

Q. What is the difference between an instance variable and a class variableInstance variables have separate values for each instance of a class. Class variables maintain a single shared value for all instances of the class, even if no instance object of that class exists.You would use the static keyword to change an instance variable into a class variable.

Q. What is the difference between method overloading and overriding
Method overloading deals

You May Also Find These Documents Helpful

Related Topics