You are on page 1of 4

1) What are the basic features of Java Language

Level(S)
Simple, Architecture neutral,,Object oriented, Portable, Distributed, High performance, 
Multithreaded, Robust, Dynamic,  Secure
2) How is a java class compiled and run ?
Level(C)
In the Java programming language, all source code is first written in plain text files ending with the 
.java extension. Those source files are then compiled into .class files by the javac compiler. A .class 
file does not contain code that is native to your processor; it instead contains bytecodes — the 
machine language of the Java Virtual Machine1 (Java VM). The java launcher tool then runs your 
application with an instance of the Java Virtual Machine.
3.What is meant by Java interpreter ? 
A.its converts the compile code into byte code which helps java to be platform independent.
4) What Is an Object?
Level: (S)
Software objects are conceptually similar to real­world objects: they too consist of state and related 
behavior. An object stores its state in fields (variables in some programming languages) and exposes 
its behavior through methods (functions in some programming languages).
5) What Is a Class?
Level: (S)
A class is a blueprint or prototype from which objects are created
6) What Is Inheritance?
Level: (S)
Object­oriented programming allows classes to inherit commonly used state and behavior from 
other classes. The base class is called the parent class and their derived classes are sub classes. In 
the Java programming language, each class is allowed to have one direct superclass, and each 
superclass has the potential for an unlimited number of subclasses:
7) What is an interface?
Level: (S)
An interface is a contract between a class and the outside world. When a class implements an 
interface, it promises to provide the behavior published by that interface.
8) Differentiate between Object­Oriented approach and procedural approach. 
Level: (C)
A major factor in the invention of Object­Oriented approach is to remove some of the flaws 
encountered with the procedural approach. 
a) 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.
Object Orientation Languages (OOPS) is concerned to develop an application based on real time 
while Procedural Programing Languages (PPL) are more concerned with the processing of 
procedures and functions. 
In OOPS, more emphasis is given on data rather than procedures, while the programs are divided 
into Objects and the data is encapsulated (Hidden) from the external environment, providing more 
security to data which is not applicable or rather possible in PPL. In PPL, its possible to expose 
Data and/or variables to the external entities which is STRICTLY restricted IN OOPS. 
In OOPS, the Objects communicate with each other via Functions while there is no communication 
in PPL rather its simply a passing values to the Arguments to the Functions and / or procedures. 
OOPS follows Bottom Up Approach of Program Execution while in PPL its Top Down approach. 
OOPS concepts includes Inheritance, Encapsulation and Data Abstraction, Late Binding, 
Polymorphism, Multithreading, and Message Passing while PPL is simply a programming in a 
traditional way of calling functions and returning values. 
In Procedural Programming :data structures + algorithms = Program
In OOPS :objects + messages = Program
Below is the list of OOPS languages :­ JAVA, VB.NET, C#.NET 
Below is the list of PPL languages :­ C, VB, Perl, Basic, FORTRAN. 
9) Explain the Encapsulation principle
Level:(M)
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. 

10) Differentiate between Encapsulation and Abstraction
Level(C)
Encapsulation has two faces; data abstraction and information hiding. Data abstraction is a type seen 
from the outside. Information hiding is a type seen from the inside.
Sometime encapsulation is used to mean information hiding only but I think the definition I gave is 
better because if you encapsulate something you get both an inside and an outside right.
Abstraction focuses on the outside view of an object (i.e. the interface)Encapsulation (information 
hiding) prevents clients from seeing its inside view, where the behavior of the abstraction is 
implemented.
11) What is Polymorphism
Level(M)
Polymorphism allows the programmer to treat derived class members just like their parent class' 
members. More precisely, Polymorphism in object­oriented programming is the ability of objects 
belonging to different data types to respond to method calls of methods of the same name, each one 
according to an appropriate type­specific behavior.
12) What is the difference between Assignment and Initialization?­ 
Assignment can be done as many times as desired whereas initialization can be done only once.
13) What are Class, Constructor and Primitive data types?­ 
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.
14) What is the difference between constructor and method?­
Constructor will be automatically invoked when an object is created whereas method has to be 
called explicitly.
15) What is casting?­ 
Casting is used to convert the value of one type to another.
16) What is the difference between an argument and a parameter?­ 
While defining method, variables passed in the method are called parameters. While using those 
methods, values passed to those variables are called arguments.
17) What is the difference between an applet and a servlet?­ 
a) Servlets are to servers what applets are to browsers. b) Applets must have graphical user 
interfaces whereas servlets have no graphical user interfaces.
18) What are Wrapper Classes ?
They are wrappers to primitive data types. They allow us to access primitives as objects.
19)Can we call finalize() method ?
Yes.  Nobody will stop us to call any method , if it is accessible in our class. But a garbage collector 
cannot call an object's finalize method if that object is reachable. 
20) What is the use of the finally block?
Finally is the block of code that executes always. The code in finally block will execute even if an 
exception is occurred. finally will not execute when the user calls System.exit().
 21) What is the difference between synchronized block and synchronized method ?
Synchronized blocks place locks for the specified block where as synchronized methods place locks 
for the entire method.
22) What is serialization and de­serialization ?
A Serialization is the process of saving the state of an object. De­serialization is the process of 
restoring the state of an object
23)What is meant by abstract class 
A. It is a partially constructed class. Without providing a complete implementation of every method. 
Any class that contains one or more abstract methods must also be declared abstract.  To declare a 
class abstract, you simply use the abstract keyword in front of the class keyword at the begining of 
the class declaration. There can be no objects of an abstract class.  That is, an abstract class cannot 
be directly instantiated with the new operator. Such objects would be useless, because as abstract 
class is not fully defined.  Also, you cannot declare abstract constructors, or abstract static methods. 
Any subclass of an abstract class must either implement all of the abstract methods in the 
superclass, or be itself declared abstract.
24)What is meant by final class, methods and variables ? 
variables ­­­­> constants
Methods  ­­­­> Cann't be overridden
Class  ­­­­> can't be inherited 
25) what is Static Member and static classes?
Static­­>1)always static members will have unique memory.
             2)only variables and methods can be declared as static, but not class.
 Reason­­>
             1)only static variables can be access in static methods.
             2)non static methods can access, both static and non static variables.
             3)static methods cannot refer to this or super in any way. 
26)What is meant by method overloading ? 
A.It is nothing but Polymorphism Ex: add(float a, float b); add(int a, int b).
In java it is possible two or more methods within the same class that share the same name,  as long 
as their parameter declarations are different.
27)What is meant by method overriding ? 
A.It is nothing but Runtime­Polymorphism Ex: add(int a, int b);in superclass  
add(int a, int b)in derived class.   When a method in a subclass has the same name and type 
signature as a method in its superclass, then the method in the subclass is said to override the 
method in the superclass.

28)What is the difference between an array and a vector ? 
A. we can increase the size of vector, were as we can not increase the size of array.(The Vector class 
provides the capability to implement a growable array of objects).

29)What is the 2 way of creating a thread ? Which is the best way and why ? 
A. you can implement the Runnable interface.(the keyword is implements).
You can extend the Thread class, itself. The easiest way to create a thread
is to create a class that implements the Runnable interface.
30)What is meant by deadlock ? 
A. a special type of error that you need to avoid that relates specifically to
multitasking is deadlock, which occurs when two threads have a circular
dependency on a pair of synchronized objects.

You might also like