Anda di halaman 1dari 5

1. Polymorphism:Polymorphism gives us the ultimate flexibility in extensibility.

The ability to
define more than one function with the same name is called Polymorphism. In java, c+
+ there are two type of polymorphism: compile time polymorphism (overloading) and
runtime polymorphism (overriding).

2. Inheritance:Inheritance is the property which allows a Child class to inherit some properties
from its parent class. In Java this is achieved by using extends keyword. Only
properties with access modifier public and protected can be accessed in child class.

3. Abstraction:Abstraction is a way to remove the association of the behaviour of an object


with the actual details behind the scenes which implement that object's behaviour.
This 'abstraction' is usually accomplished through the use of base classes with virtual
functions; each derived function provides the details that implement the behaviour
behind that abstraction.

4. Compile-time polymorphism:In compiletime Polymorphism, method to be invoked is determined at the


compile time. Compile time polymorphism is supported through the method
overloading concept in java. Method overloading means having multiple methods
with same name but with different signature (number, type and order of parameters).

5. Runtime Polymorphism:In runtime polymorphism, the method to be invoked is determined at the run
time. The example of run time polymorphism is method overriding. When a subclass
contains a method with the same name and signature as in the super class then it is
called as method overriding.

6. Encapsulation:Encapsulation is the process of binding together the methods and data variables
as a single entity. It keeps both the data and functionality code safe from the outside
world. It hides the data within the class and makes it available only through the
methods. Java provides different accessibility scopes (public, protected, private
,default) to hide the data from outside. Here we provide a example in which we create
a class "Check" which has a variable "amount" to store the current amount. Now to
manipulate this variable we create a methods and to set the value of amount we create
setAmount() method and to get the value of amount we create getAmount() method .

7. Methods:A method is basically a behavior. A class can contain many methods. It is in methods
where the logics are written, data is manipulated and all the actions are executed.

8. Enum:Enums restrict a variable to have one of only a few predefined values. The
values in this enumerated list are called enums. With the use of enums it is possible to
reduce the number of bugs in your code. For example if we consider an application
for a fresh juice shop it would be possible to restrict the glass size to small, medium
and Large.

9. Java throws an exception:When your program causes an error, Java throws an exception. Java then
throws this exception to a part of the program that will catch it. You shouldn't try to
catch most exceptions, but you should catch all exceptions that are caused by events
which you have no control over - exceptions caused by bad user input or I/O
problems.

10. Static/Class methods:There are two types of methods.

Instance methods are associated with an object and use the instance variables of
that object. This is the default.
Static methods use no instance variables of any object of the class they are
defined in.

11. Nested Class:The Nested classes are classes which are defined within another class. A nested
class has access to the members including private members of the class in which it is
reside. But the enclosing class does not have access to the members of the nested
class.
Nested classes are of two types :
1. Static
2. Non-static

12. Two dimension arrays:In java, multidimensional arrays are actually arrays of arrays. For example, you can
declare a two dimensional array as :
int twoD[][]=new int [4][5];
You can also declare a three dimensional array as :
int threeD[][][]= new int [3][4][5];

13. Bitwise Operators:Java's bitwise operators operate on individual bits of integer (int and long)
values. If an operand is shorter than an int, it is promoted to int before doing the
operations. It helps to know how integers are represented in binary. For example the
decimal number 3 is represented as 11 in binary and the decimal number 5 is
represented as 101 in binary. Negative integers are store in two's complement form.

14. What do you understand by Synchronization:Answer: Synchronization is a process of controlling the access of shared resources by
the multiple threads in such a manner that only one thread can access one resource at a
time. In non synchronized multithreaded application, it is possible for one thread to
modify a shared object while another thread is in the process of using or updating the
object's value. Synchronization prevents such type of data corruption.

15. How to define an Interface:In Java Interface defines the methods but does not implement them. Interface
can include constants. A class that implements the interfaces is bound to implement all
the methods defined in Interface.

16. Garbage Collector :When we create an object by instantiating a class, the object is put on the heap,
that is, it uses some memory. A Java application creates and uses objects. After an
object in memory has been used and is no longer needed, it is sensible to free memory
from that object.The Garbage Collector in Java initiates the memory management by
freeing up the memory from objects that are no longer referenced. The importance of
this is that you do not need to code the memory management into your application
program, also you have no control over when the garbage collector runs. While coding
in some application we can do following things in order to help the memory
management through the garbage collector :
1. Firstly, make an object eligible for the garbage collection, as garbage
collector will only free memory from an eligible object.
2. Also make a request for garbage collection by making a system call to the
garbage collector via, System.gc();.

17. Protected Modifier :-

The protected modifier makes a class member more visible than private
modifier but less accessible than public modifier. This modifier may be applied only
to class members viz. variables, methods, and inner classesbut not to the class itself.
A class member declared protected is visible to the following elements:
1.The classes in the same package that contains the class that owns the
protected member.
2.The subclasses of the class that owns the protected member. These subclasses
have access even if they are not in the same package as the parent class.

18. What is finalization and what is its purpose:Sometimes an object will need to perform some action when it is destroyed, to
handle such situation; Java provides a mechanism called finalization. By using
finalization, we can define specific actions that will occur when an object is just about
to be cleaned by the gc or garbage-collector. The runtime of Java calls this method
whenever it is about to clean an object of that class.

19. How can we use beans in JSP:Java Beans are reusable components. They are used to separate Business Logic
from Presentation Logic. Internally a bean is just an instance of a class. JSPs provide
three basic tags for working with Beans.

20. What is implicit casting? What is explicit casting:Implicit casting is the process of simply assigning one entity to another without
any transformation guidance to the compiler. This type of casting is not permitted in
all kinds of transformations and may not work for all scenarios. Explicit casting in the
process in which the complier are specifically informed to about transforming the
object.

Anda mungkin juga menyukai