Beruflich Dokumente
Kultur Dokumente
Ans:
There are 6 types of method support by java .They are
i. Static Method
ii. Non Static Method
iii. Final Method
iv. Abstract Method
v. Native Method
vi. Synchronized Method.
Ans:
If the method declares with Static modifier it should declare as static method. If
the method declare without any Static modifier known as non-static method.
Ans:
Final keyword can be used in 3 different place all over in java
i. If the Variable is final it cannot be modified.
ii. If the method is final cannot override.
iii. If the class is final it cannot be override.
Ans:
If the method declare with native modifier ten it is known as native modifier. And
This method is use to communicate from java application to other environment
like C & C++.
Ans:
Abstraction is the concept of representing the essential feature without including
the background details & explanation.
Ans:
Abstract is a keyword in java which supports the concept of abstraction.
7. What is interface?
Ans:
It is a description of a set of method that conforming implementing classes must
have.
Ans:
The difference between both is
i. Interface supports 100% abstraction WHERE abstract class support 0-
100% abstraction.
ii. All method of Interface are implicitly public & abstract WHERE user can
declare any type of method in abstract class.
iii. The nature of variable in case of interface is public, static &final
WHERE user can declare any kind of variable in case of abstract class.
iv. Interface support the concept of Multiple inheritance WHERE Abstract
class never support it.
v. Constructor cannot design in interface but it possible in case of
abstract class.
10. What is the procedure to call a non - static and static method in java?
Ans:
Static method can be called directly with in the same class and it can be called by
class name or object name with in the same or different class.
Non static method can be called by the object only.
Ans:
When class not able to instantiate and able to contains complete as well as
abstract method.
Ans:
If the method declare as protected it may accessed with in inside the same class,
in same package/folder, and outside the package/folder (if inherited).
Ans:
If the method declares with Final it cannot override.
14. Can we have two methods in a class with the same name?
Ans:
Yes name of two method may be same within a single class, it is the concept of
overloading.
15. How can we pass argument to a function by reference instead of pass by value?
Ans:
By Object passing
16. Which methods have no body?
Ans:
Abstract methods have no body.
An:
Interface keyword used to define user define interface in java.
Ans:
The nature of variable in case of interface is Public, Static and Final.
Ans:
Abstract class never supports multiple inheritance. Because it creates ambiguity
of members.
Ans:
No abstract class cannot be instantiated.
Ans:
Yes, it is possible to design constructor in abstract class.
Ans:
Not possible within that abstract class, but the constructor of abstract class
automatically invoked when programmer creates the object of sub class.
Ans:
Native method is used to communicate from java to other environment.
24. Which method indicate compiler not to check existence of method at compilation?
Ans:
Native method indicate compiler not to check existence of method at compilation.