Today I will share with you some questions on basics of Java.
Q. What are the three OOPs principles and their defination?
Ans : Encapsulation, Inheritance and Polymorphism are the three OOPs principles.
Encapsulation:Is the Mechanism that binds together code and the data it manipulates, and keeps both safe from outside interference and misuse.
Inheritance:Is the process by which one object acquires the properties of another object.
Polymorphism:Is a feature that allows one interface to be used for a general class of actions.
Q. What is a compilation unit?
Ans : Java source code file.
Q. What is the difference between constructor and method?
Ans : A constructor creates an instance of a class. They are not inherited. A method is a group of java statements. Methods are intereted.
Q. What is meant by variable?
Ans: Variables are locations in memory that can hold values. Before assigning any value to a variable, it must be declared.
Q. What are the kinds of variables in Java and what are their uses?
Ans: Java has three kinds of variables namely, the instance variable, the local variable and the class variable.
Local variables are used inside blocks as counters or in methods as temporary variables and are used to store information needed by a single method.
Instance variables are used to define attributes or the state of a particular object and are used to store information needed by multiple methods in the objects.
Class variables are global to a class and to all the instances of the class and are useful for communicating between different objects of all the same class or keeping track of global states.
I will be sharing with you more Q&A soon...
Keep Reading....
Cheers
Padhaku Einstein
No comments:
Post a Comment