Sie sind auf Seite 1von 5

1.

Polymorphism:Polymorphisms is nothing but ability to take more than one forms(One


Interface,Multiple Methods or One Name,Many Forms).

2. Inheritance:The Process of deriving new class from existing class.This is called Inheritance.
New Class-Child Class
Existing Class-Parent Class

3. Abstraction:we invented flight based on the mechanism of Birds. So flight is derived form
the base of birds.

4. Compile-time polymorphism:Compile time polymorphism: calculating area of square and rectangle


(different classes, square and rectangle have a function called area() which takes
different arguments (for square only one argument and for rectangle two arguments-) )

5. Runtime Polymorphism:-

Run time polymorphism: Bank Account, savings and current (here, acoount
class is the base class, savings and current account are derived classes, the objects of
each are created at runtime)

6. Encapsulation:Encapsulation is nothing but wrapping the data and functions into single entity.

7. Methods:One disadvantage of using polymorphism in code is that while reading code


you don't know the actual type which annoys while you are looking to find bugs or
trying to debug program. But if you do java debugging in IDE you will definitely be
able to see the actual object and the method call and variable associated with it.

8. Enum:This would make sure that it would not allow anyone to order any size other
than the small, medium or large.

9. Java throws an exception:There are many arguments for and against both checked and unchecked, and
whether to use checked exceptions at all. I will go through the most common
arguments throughout this text. Before I do so, let me just make one thing clear.
Checked and unchecked exceptions are functionally equivalent. There is nothing you
can do with checked exceptions that cannot also be done with unchecked exceptions,
and vice versa.

10. Static/Class methods:If you define a method to be static, you will be given a rude message by the
compiler if you try to access any instance variables. You can access static variables,
but except for constants, this is unusual. Static methods typically take all they data
from parameters and compute something from those parameters, with no reference to
variables. This is typical of methods which do some kind of generic calculation. A
good example of this are the many utility methods in the predefined Math class.

10. Static/Class methods:-

From outside the defining class, an instance method is called by prefixing it with an
object, which is then passed as an implicit parameter to the instance method, eg,
inputTF.setText(""); A static method is called by prefixing it with a class name, eg,
Math.max(i,j);. Curiously, it can also be qualified with an object, which will be
ignored, but the class of the object will be used.

11. Nested Class:Static nested class : The nested class which is defined with 'static' modifier is
known as 'static nested class'. Static nested class can access the member of it's
enclosing class through an object. It can't access these member directly.
Non-Static nested class : The non-static nested class or inner class has access to all
the members of it's enclosing class or outer class directly in the same way that other
non-static member of outer class do.
Example : Simple inner class

12. Two dimension arrays:There are a couple of interesting consequences of this: Rows may be different
sizes. Also, each row is an object (an array) that can be used independently.

13. Bitwise Operators:For example, -4 is 1111 1111 1111 1111 1111 1111 1111 1100.

14. What do you understand by Synchronization:E.g. Synchronizing a function:


public synchronized void Method1 () {
// Appropriate method-related code.
}

15. How to define an Interface:-

Interfaces support multiple inheritance; classes do not. Interfaces contain only public
members; classes do not have to. Interfaces do not have superclasses, except the
implicit 'Object' supertype; they have superinterfaces. Nested interfaces are always
static, never inner, unlike classes which can be inner classes. "u" is not an English
pronoun.

16. Garbage Collector :We can also invoke the gc() method by using an instance of the Runtime class
that a running program always has. It is contained in java.lang package, we can get
hold of this instance by calling the static method getRuntime() of the Runtime class.
The following example will show how we can invoke gc() method via Runtime class
and some other runtime tasks,

17. Protected Modifier :Variables, methods and constructors which are declared protected in a superclass can
be accessed only by the subclasses in other package or any class within the package of
the protected members' class. The protected access modifier cannot be applied to class
and interfaces. Methods, fields can be declared protected, however methods and fields
in a interface cannot be declared protected. Protected access gives the subclass a
chance to use the helper method or variable, while preventing a nonrelated class from
trying to use it.

18. What is finalization and what is its purpose:Java uses finalize() method for Garbage collection.

19. How can we use beans in JSP:A Bean obtains all the benefits of Java's "write-once, run-anywhere" paradigm. The
properties, events, and methods of a Bean that are exposed to an application builder
tool can be controlled. A Bean may be designed to operate correctly in different
locales, which makes it useful in global markets.

20. What is implicit casting? What is explicit casting:This type of casting is not permitted in all kinds of transformations and may not
workout for all application scenarios. Explicit casting in the process in which the
complier are specifically informed to about transforming the object.

Das könnte Ihnen auch gefallen