Java Interview Question Solve ,Set 1

Q1- Describe the principles of OOPS? 
There are three main principals of oops which are called Poly

Q1- Describe the principles of OOPS? 

There are three main principals of oops which are called Polymorphism, Inheritance and Encapsulation.
i) Encapsulation is a process of binding or wrapping the data and the codes that operates on the data into a single entity. This keeps the data safe from outside interface and misuse. One way to think about encapsulation is as a protective wrapper that prevents code and data from being arbitrarily accessed by other code defined outside the wrapper.
ii) Inheritance is the process by which one object acquires the properties of another object. The meaning of Polymorphism is something like one name many forms. Polymorphism enables one entity to be used as as general category for different types of actions. The specific action is determined by the exact nature of the situation.
iii) The concept of polymorphism can be explained as “one interface, multiple methods”.

Q2-What is a Java package and how is it used? 

A Java package is a naming context for classes and interfaces. A package is used to create a separate name space for groups of classes and interfaces. Packages are a good way to organize related classes and interfaces into a single API unit and to control accessibility to these classes and interfaces.

Q3-Can an Interface be final? 

No, because we have to provide for implementation of the methods in the interface in the class which implements the interface.

Q4-Can we define private and protected modifiers for variables in interfaces? 

No .

Q5-How you can force the garbage collection? 

Garbage collection is an automatic process in Java and can’t be forced.

Q6-Explain the different forms of Polymorphism? 

From a practical programming viewpoint, polymorphism exists in three distinct forms in Java: Method overloading, Method overriding through inheritance , Method overriding through the Java interface .

Q7-Is sizeof a keyword? 

The sizeof operator is not a keyword.

Q8-What modifiers are allowed for methods in an Interface? 

Only public and abstract modifiers are allowed for methods in interfaces. Protected or private is not allowed.

Leave a Reply

Your email address will not be published. Required fields are marked *

64  ⁄  64  =