0% found this document useful (0 votes)
17 views

Java 2.0 Theory

The document discusses Java class hierarchies and how they allow common attributes and behaviors to be defined once and shared between classes to reduce duplicate code. It also discusses polymorphism in Java, the different types including compile-time and run-time, and data abstraction which hides details and shows essential information.

Uploaded by

anishtakwale111
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Java 2.0 Theory

The document discusses Java class hierarchies and how they allow common attributes and behaviors to be defined once and shared between classes to reduce duplicate code. It also discusses polymorphism in Java, the different types including compile-time and run-time, and data abstraction which hides details and shows essential information.

Uploaded by

anishtakwale111
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

JAVA 8 CLASS HEIRCHY

defining objects as a new kind of data structure simply involves

crea ng new classes, each in their own file (e.g., Car, Person, Address, Bank, etc..). In fact,

a defini on of the word ‘class’ in English is:

"A collec on of things sharing a common a ribute".

All object-oriented languages (e.g., JAVA) allow you to organize your classes in a way that allows you
to take advantage of the commonality between classes. That is, we can define a class with certain
a ributes (and/or behaviors) and then specify which other classes share those same a ributes
(and/or behaviors). As a result, we can greatly reduce the amount of duplicate code that we would
be wri ng by not having to re-define the common a ributes and/or behaviors for all of the classes
that share such common features. JAVA accomplishes this task by arranging all of its classes in a
"family-tree”- like ordering called a class hierarchy. A class hierarchy is o en represented as an
upside down tree (i.e., the root of the tree at the top). The more “general” kinds of objects are
higher up the tree and the more “specific” (or specialized) kinds of objects are below them in the
hierarchy. So, a child object defined in the tree is a more specific kind of object than its parent or
ancestors in the tree

JAVA 9
Polymorphism is derived from two Greek words, “poly” and “morph”, which mean “many”
and “forms”, respectively. Hence, polymorphism meaning in Java refers to the ability of
objects to take on many forms. In other words, it allows different objects to respond to
the same message or method call in multiple ways.
Polymorphism allows coders to write code that can work with objects of multiple
classes in a generic way without knowing the specific class of each object.

Types of Polymorphism

There are two main types of polymorphism in Java: compile- me and run me.
Data abstrac on is the process of hiding certain details and showing only essen al informa on to the
user.

Abstrac on can be achieved with either abstract classes or interfaces (which you will learn more
about in the next chapter).

The abstract keyword is a non-access modifier, used for classes and methods:

Abstract class: is a restricted class that cannot be used to create objects (to access it, it must be
inherited from another class).

Abstract method: can only be used in an abstract class, and it does not have a body. The body is
provided by the subclass (inherited from).

JAVA 10

Java Swing tutorial is a part of Java Foundation Classes (JFC) that is used to create window-
based applications. It is built on the top of AWT (Abstract Windowing Toolkit) API and
entirely written in java.

Unlike AWT, Java Swing provides platform-independent and lightweight components.

The javax.swing package provides classes for java swing API such as JButton, JTextField,
JTextArea, JRadioButton, JCheckbox, JMenu, JColorChooser etc.

You might also like