Friday, May 9, 2008

Java Interview Questions 39

191. What is the difference between procedural and object-oriented programs?
Ans. In procedural program, programming logic follows certain procedures and the
instructions are executed one after another. In OOP program, unit of program is
object, which is nothing but combination of data and code. b) In procedural
program, data is exposed to the whole program whereas in OOPs program, it is
accessible with in the object and which in turn assures the security of the code.

192. What are Encapsulation, Inheritance and Polymorphism?
Ans. Encapsulation is the mechanism that binds together code and 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 the feature that allows one interface to be used for general class
actions.

193. What is the difference between Assignment and Initialization?-
Ans. Assignment can be done as many times as desired whereas initialization can be
done only once.

194. What is OOPs?-
Ans. Object oriented programming organizes a program around its data, i. e. ,
objects and a set of well defined interfaces to that data. An object-oriented
program can be characterized as data controlling access to code.

195. What are Class, Constructor and Primitive data types?
Ans. Class is a template for multiple objects with similar features and it is a
blue print for objects. It defines a type of object according to the data the
object can hold and the operations the object can perform. Constructor is a special
kind of method that determines how an object is initialized when created. Primitive
data types are 8 types and they are: byte, short, int, long, float, double,
boolean, char.

No comments:

Useful Information