2. What are the Main features of Java?
Object Oriented: Java is an object Oriented language where everything is
done keeping objects (data) in mind.
Simple: Java is very easy to learn and follow. It’s syntax are very easy . Any
programmer who has some basic knowledge about any object oriented
language like c++ can easily follow Java.
Platform Independent: Java is a write once, run everywhere language. That
means java program written on one platform can be run on any other
platforms without much difficulties.
Secured: Java is a highly secured language through which you can develop
virus-free and highly secured applications
Robust: Java is a robust because of automatic garbage collection, better
exception and error handling mechanism, no explicit use of pointers and
better memory management system.
3. What are the Main features of Java?
Portable: Java is portable because you can run java byte code on any
hardware which has compliant JVM which converts byte-code according to
that particular hardware.
Multithreaded: Java supports multithreaded programming where multiple
threads execute their task simultaneously.
Distributed: Java is distributed because you can develop distributed large
applications using Java concepts like RMI and EJB.
Dynamic: Java is a dynamic language because it supports loading of classes on
demand.
Extensible: You can develop new classes using existing interfaces, you can
declare new methods
4. What are the Main features of Java?
Functional Style Programming: With the introduction of lambda expressions,
functional interfaces and Stream API in Java 8 you can also write
Functional style of programming in Java
5. What is the latest version of Java?
Java 17 or JDK 17 is the latest version of Java which is released on September
14, 2021. (Keep checking Oracle website for latest Java releases).
6. What are the fundamental principles
of object oriented programming?
Inheritance
Abstraction
Polymorphism
Encapsulation
7. What do you mean by inheritance in
Java?
Inheritance is one of the key principle of object oriented programming.
Through inheritance, one class can inherit the properties of another class.
The class from which properties are inherited is called super class and the
class to which properties are inherited is called sub class.
8. What are the different types of
inheritance?
a) Single Inheritance : One class is extended by only one class.
b) Multilevel Inheritance : One class is extended by a class and that class in turn is extended
by another class thus forming a chain of inheritance.
c) Hierarchical Inheritance : One class is extended by many classes. Her class thus forming a
chain of inheritance.
d) Hybrid Inheritance : It is a combination of above types of inheritance.
e) Multiple Inheritance : One class extends more than one classes. (Java does not support
multiple inheritance)
6) does Java supports multiple inheritance? If not, why?
To avoid ambiguity, complexity and confusion, Java does not supports multiple inheritance.
i.e. a class in Java can not extend more than one classes. For example, if Class C extends
Class A and Class B which have a method with same name, then Class C will have two
methods with same name. This causes ambiguity and confusion for which method to use. To
avoid this, Java does not supports multiple inheritance.
9. What are the different types of
inheritance?
a) Single Inheritance : One class is extended by only one class.
b) Multilevel Inheritance : One class is extended by a class and that class in
turn is extended by another class thus forming a chain of inheritance.
c) Hierarchical Inheritance : One class is extended by many classes. Her class
thus forming a chain of inheritance.
d) Hybrid Inheritance : It is a combination of above types of inheritance.
e) Multiple Inheritance : One class extends more than one classes. (Java does
not support multiple inheritance)
10. does Java supports multiple
inheritance? If not, why?
To avoid ambiguity, complexity and confusion, Java does not supports
multiple inheritance. i.e. a class in Java can not extend more than one
classes. For example, if Class C extends Class A and Class B which have a
method with same name, then Class C will have two methods with same
name. This causes ambiguity and confusion for which method to use. To avoid
this, Java does not supports multiple inheritance.
11. If Java doesn’t supports multiple
inheritance, then how do you implement
multiple inheritance in Java?
Through interfaces, we can implement multiple inheritance in Java. A class in
Java can not extend more than one classes, but a class can implement more
than one interfaces.
12. What is the parent class of all classes
in Java?
Java.lang.Object class
13. You know that all classes in Java are
inherited from java.lang.Object class. Do
interfaces also inherited from
java.lang.Object class?
No only classes in Java are inherited from java.lang.object class. Interfaces in
Java are not inherited from java.lang.object class. But, classes which
implement interfaces are inherited from java.lang.Object Class
14. How do you restrict a member of a class
from inheriting to it’s sub classes?
By declaring that member as a private. Because, private members are not
inherited to sub classes.
15. Can a class extend itself?
No, a class can not extend itself.