Contact Us || Privacy Policy || About Us |
|
Core Java OOPs Concepts Interview Question .1) Difference between object oriented programming language and object based programming language?→ Object based programming languages follow all the features of OOPs except Inheritance. Examples of object based programming languages are JavaScript, VBScript etc. 2) What is constructor
3) What is the default constructor ?→ if there is no constructor in the class java compiler creates a default constructor. And Default constructor provides the default values to the objects. → Default Constructor" when it doesn't have any parameter. It is called . 4) What Does constructor return any value ?→ yes, that is current instance . 5) Is constructor inherited ?→ constructor is not inherited. 6) Can you use a constructor with final?→ No, constructor can't be final. 7) What is static variable ?→ static variable gets memory only once in class area at the time of class loading. → static variable is used to refer the common property of all objects. 8) What is static method?→ static method can access static data member and can change the value of it. → A static method belongs to the class rather than object of a class. 9) Why main method is static?→ If main method were not declared static than JVM has to create instance of main Class and since constructor can be overloaded and can have arguments there would not be any certain and consistent way for JVM to find main method in Java.Since the main method is static Java virtual Machine can call it without creating any instance of a class which contains the main method. 10) What is static block?→ Static block initialize the static data member. 11) What is "this" keyword in java ?→ this:- It is a keyword , that refers to the current object → Used to refer current class instance variable. → To current class constructor. → It can be passed an argument in the method call. → It can be passed argument in the constructor call. → Used to return the current class instance. → Used to invoke current class method 12) What is Inheritance ?→ It represents the IS-A relationship, also known as parent-child relationship. → One object acquires all the properties and behaviors of parent object. → Inheritance allows a class to use the properties and methods of another class. → In Inheritance allowed, a class to inherit property of another class. When a Class extends another class it inherits all members including fields and methods. such as Parent - Child relationship. More details13) What is method overloading?→ If class contains multiple method, same name but different parameter is know as Method Overloading 14) What is method overriding ?→ Same method and same parameter know as Method Overriding . 15) What is Difference between method Overloading and method Overriding.
16) What is final variable, final method, and final class?final variable : If you make any variable as final, you cannot change the value of final variable. final method :A final method is a method that can't be overriden. final class : A final class that can not be overriden or inherited.. 17) What is blank final variable?In java , A blank final variable that is not initalized at the time of declaration, is known as blank final variable. 18) Can we intialize blank final variable?Yes! You can initialize a blank final variable in constructor or static block block. 19) Can you declare the main method as final in java ?Yes. You can declare main method as final But, In inheritance concept we cannot declare main method as final in parent class because create compile time error. 20) What is Polymorphism ?Polymorphism is one of the OOPs concepts that allows us to perform a single action in different ways. the best example of Social media There are Two types of Polymorphism that is.
|