The lecture was condcuted by Tushar B Kute at YCMOU, Nashik through VLC orgnanized by MSBTE. The contents can be found in book "Core Java Programming - A Practical Approach' by Laxmi Publications.
Java abstract class & abstract methods,Abstract class in java
Abstract classes are classes that contain one or more abstract methods. An abstract method is a method that is declared, but contains no implementation. Abstract classes may not be instantiated, and require subclasses to provide implementations for the abstract methods.
Java abstract class & abstract methods,Abstract class in java
Abstract classes are classes that contain one or more abstract methods. An abstract method is a method that is declared, but contains no implementation. Abstract classes may not be instantiated, and require subclasses to provide implementations for the abstract methods.
oops concept in java | object oriented programming in javaCPD INDIA
object oriented programming is a key concept for the development of application in windows as well as web based application environment. oops concept maps real world through its concept of classes, objects, inheritance, polymorphism which help in making a robust application.
What is the DOM?
The DOM is a W3C (World Wide Web Consortium) standard.
The DOM defines a standard for accessing documents:
"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."
The W3C DOM standard is separated into 3 different parts:
Core DOM - standard model for all document types
XML DOM - standard model for XML documents
HTML DOM - standard model for HTML documents
The HTML DOM (Document Object Model)
When a web page is loaded, the browser creates a Document Object Model of the page.
The HTML DOM model is constructed as a tree of Objects.
With the HTML DOM, JavaScript can access and change all the elements of an HTML document.
oops concept in java | object oriented programming in javaCPD INDIA
object oriented programming is a key concept for the development of application in windows as well as web based application environment. oops concept maps real world through its concept of classes, objects, inheritance, polymorphism which help in making a robust application.
What is the DOM?
The DOM is a W3C (World Wide Web Consortium) standard.
The DOM defines a standard for accessing documents:
"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."
The W3C DOM standard is separated into 3 different parts:
Core DOM - standard model for all document types
XML DOM - standard model for XML documents
HTML DOM - standard model for HTML documents
The HTML DOM (Document Object Model)
When a web page is loaded, the browser creates a Document Object Model of the page.
The HTML DOM model is constructed as a tree of Objects.
With the HTML DOM, JavaScript can access and change all the elements of an HTML document.
main() method is starting execution block of a java program.
If any java class contain main() method known as main class.
http://www.tutorial4us.com/java/java-main-method
Polymorphism in java, method overloading and method overridingJavaTportal
Polymorphism come from the two Greek words ‘poly’ meaning many and ‘morphs” meaning forms. The ability to exist in different form is called polymorphism. The same variable or method can perform different tasks; the programmer has the advantage of writing flexible code.
Java is a relevant subject area taught in all computer science degree programs. This object-oriented computer language is used to write a variety of Software Applications.
Introduction to Object Oriented ProgrammingMoutaz Haddara
An Introduction to Object-Oriented Programming (OOP)
Download the presentation to view it correctly, as it has some animations that won't show here.
If you have any questions, please contact me. You are free to use it this presentation, but it would be nice at least to give me some credit :)
Content:
1- History of Programming
2. Objects and Classes
3- Abstraction, Inheritance, Encapsulation, and Polymorphism
Class object method constructors in javaRaja Sekhar
Presented By :
N.V.Raja Sekhar Reddy
www.technolamp.co.in
www.programming9.com
Want more interesting...
Watch and Like us @ https://www.facebook.com/Technolamp.co.in
subscribe videos @ http://www.youtube.com/user/nvrajasekhar
To learn about the basic concepts of Object Oriented Programming and Inheritance plus different Inheritance Models and interview questions will be covered.
Apache Pig: Introduction, Description, Installation, Pig Latin Commands, Use, Examples, Usefulness are demonstrated in this presentation.
Tushar B. Kute
Researcher,
http://tusharkute.com
Ubuntu OS and it Flavours-
UbuntuKylin
Ubuntu Server
Ubuntu Touch
Ubuntu GNOME
Ubuntu MATE
Kubuntu
Lubuntu
Xubuntu
Edubuntu
MythBuntu
Ubuntu Studio
Blackbuntu
Linux Mint
Tushar B. Kute,
http://tusharkute.com
Part 04 Creating a System Call in LinuxTushar B Kute
Presentation on "System Call creation in Linux".
Presented at Army Institute of Technology, Pune for FDP on "Basics of Linux Kernel Programming". by Tushar B Kute (http://tusharkute.com).
Part 03 File System Implementation in LinuxTushar B Kute
Presentation on "Virtual File System Implementation in Linux".
Presented at Army Institute of Technology, Pune for FDP on "Basics of Linux Kernel Programming". by Tushar B Kute (http://tusharkute.com).
Part 02 Linux Kernel Module ProgrammingTushar B Kute
Presentation on "Linux Kernel Module Programming".
Presented at Army Institute of Technology, Pune for FDP on "Basics of Linux Kernel Programming". by Tushar B Kute (http://tusharkute.com).
Part 01 Linux Kernel Compilation (Ubuntu)Tushar B Kute
Presentation on "Linux Kernel Compilation" (Ubuntu based).
Presented at Army Institute of Technology, Pune for FDP on "Basics of Linux Kernel Programming". by Tushar B Kute (http://tusharkute.com).
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B KuteTushar B Kute
Recent And Future Trends In Os
Linux Kernel Module Programming, Embedded Operating Systems: Characteristics of Embedded Systems, Embedded Linux, and Application specific OS. Basic services of NACH Operating System.
Introduction to Service Oriented Operating System (SOOS), Introduction to Ubuntu EDGE OS.
Designed By : Tushar B Kute (http://tusharkute.com)
Chapter 01 Introduction to Java by Tushar B KuteTushar B Kute
The lecture was condcuted by Tushar B Kute at YCMOU, Nashik through VLC orgnanized by MSBTE. The contents can be found in book "Core Java Programming - A Practical Approach' by Laxmi Publications.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Let's dive deeper into the world of ODC! Ricardo Alves (OutSystems) will join us to tell all about the new Data Fabric. After that, Sezen de Bruijn (OutSystems) will get into the details on how to best design a sturdy architecture within ODC.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
"Impact of front-end architecture on development cost", Viktor TurskyiFwdays
I have heard many times that architecture is not important for the front-end. Also, many times I have seen how developers implement features on the front-end just following the standard rules for a framework and think that this is enough to successfully launch the project, and then the project fails. How to prevent this and what approach to choose? I have launched dozens of complex projects and during the talk we will analyze which approaches have worked for me and which have not.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
Neuro-symbolic (NeSy) AI is on the rise. However, simply machine learning on just any symbolic structure is not sufficient to really harvest the gains of NeSy. These will only be gained when the symbolic structures have an actual semantics. I give an operational definition of semantics as “predictable inference”.
All of this illustrated with link prediction over knowledge graphs, but the argument is general.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
1. Java Programming
Semester- V
Course: CO/CM/IF
Tushar B Kute,
Assistant Professor,
Sandip Institute of Technology and Research Centre, Nashik.
2. Objectives
● To create classes, objects and make use of
arrays and strings.
● They will also learn the concepts of inheritance
and garbage collection.
3. Class
● A class is a user-defined data type with the
template that serves to define its properties.
● A class defines new data type. Once defined,
this new data type can be used to create
objects of that type.
● Class is a template for an object and object is
the instance of the class.
4. Class definition
class class-name
{
data-type instance-variable1;
data-type instance-variable2;
- - - - -;
data-type instance-variableN;
data-type method-name1(parameter-list)
{
//body of the method1
}
data-type method-name2(parameter-list)
{
//body of the method2
}
- - - - -;
data-type method-nameN(parameter-list)
{
//body of the methodN
}
}
5. Adding variables to class
class Country
{
long population;
float currencyRate;
int noOfStates;
}
6. Creating objects
Creating the objects of the class is also called
as instantiating an object.
Example:
Country japan; // declaration
japan = new Country(); // instantiation or
Country japan = new Country();
10. Adding methods
The general form of the declaration of the method is,
data-type method-name (parameter-list)
{
Body of the method;
}
The method declaration contains four different parts:
● Name of the method (method-name)
● Data type of the values returned by method (data-type)
● The list of parameters (parameter-list)
● Body of the method
11. What is a method?
float area(int radius)
{
final float pi = 3.14f;
float val;
val = pi * (float) (radius * radius);
return(val);
}
12. Constructor
● A constructor initializes an object immediately upon
creation.
● It has the same name as the class in which it
resides and it is syntactically similar to a method.
● Once defined, the constructor is automatically
called immediately after the object is created,
before the new operator completes.
● Constructors look a little strange because they
have no return type, not even void.
13. Example:
class Country
{
long population;
int noOfStates;
float currancyRate;
Country(long x, int y) {
population = x;
noOfStates = y;
}
}
void display()
{
System.out.println(“Population:”+population);
System.out.println(“No of states:”+noOfStates);
}
}
14. Garbage Collection
● Automatic garbage collection is the process of
looking at heap memory, identifying which objects
are in use and which are not, and deleting the
unused objects.
● An in use object, or a referenced object, means
that some part of your program still maintains a
pointer to that object.
● An unused object, or unreferenced object, is no
longer referenced by any part of your program. So
the memory used by an unreferenced object can
be reclaimed.
15. Finalize method
● finalize method in java is a special method
much like main method in java. finalize() is
called before Garbage collector reclaim the
Object, its last chance for any object to perform
cleanup activity i.e. releasing any system
resources held, closing connection if open etc.
16. Example:
protected void finalize( ) throws Throwable {
try {
System.out.println("Finalize of Sub Class");
//release resources, perform cleanup ;
} catch(Throwable t) {
throw t;
} finally {
System.out.println("Calling finalize of Super Class");
super.finalize();
}
}
18. Example (Constructor Overloading):
class Box
{
int height;
int depth;
int length;
Box()
{
height = depth = length = 10;
}
Box(int x,int y)
{
height = x;
depth = y;
}
}
19. The 'this' keyword
● Many times it is necessary to refer to its own
object in a method or a constructor.
● To allow this Java defines the ‘this’ keyword. If we
are familiar with C++, it is not hard to learn and
understand the concept of ‘this’ keyword.
● The ‘this’ is used inside the method or constructor
to refer its own object.
● That is, ‘this’ is always a reference to the object of
the current class’ type.
20. Example:
class Box
{
int height;
int depth;
int length;
Box(int height, int depth, int length)
{
this.height = height;
this.depth = depth;
this.length = length;
}
}
21. Method overloading
● In Java it is possible to define two or more
methods within the same class that are having
the same name, but their parameter declarations
are different.
● In the case, the methods are said to be
overloaded, and the process is referred to as
method overloading.
● Method overloading is one of the ways of Java
implementation of polymorphism.
22. Example:
int add(int x, int y) //version1
{
cal = x + y;
return(cal);
}
int add(int z) //version2
{
cal = z + 10;
return(cal);
}
float add(float x, float y) //version3
{
val = x + y;
return(val);
}
23. Static members
● Methods and variables defined inside the class
are called as instance methods and instance
variables. That is, a separate copy of them is
created upon creation of each new object.
● But in some cases it is necessary to define a
member that is common to all the objects and
accessed without using a particular object.
● That is, the member belongs to the class as a
whole rather than the objects created from the
class. Such members can be created by
preceding them with the keyword static.
25. Static members
● When a member is declared static, it can be accessed
before any objects of its class are created, and without
reference to any object.
● We can declare both methods and variables to be static.
● The most common example of a static member is
main( ). main( ) is declared as static because it must be
called before any objects exist.
● Instance variables declared as static are, essentially,
global variables.
26. Restrictions to static
● They can only call other static methods.
● They must only access static data.
● They cannot refer to this or super in any way.
31. Command line and variable length of
arguments
javac prog.java
java prog Hello my name is Tushar
args[0] = Hello
args[1] = my
args[2] = name
args[3] = is
args[4] = Tushar
32. The Object class
● There is one special class, ‘Object’, defined by Java.
● All other classes are subclasses of ‘Object’. That is,
‘Object’ is a super class of all other classes.
● This means that a reference variable of type ‘Object’
can refer to an object of any other class.
● Also, since arrays are implemented as classes, a
variable of type ‘Object’ can also refer to any array.
35. Public access
● If we declare any variable and method as
‘public’, it will be accessible to all the entire
class and visible to all the classes outside the
class. It can be accessed from outside package
also. For example,
public int val;
public void display();
37. Protected access
● A protected member is accessible in all classes in the
package containing its class and by and by all subclasses of
its class in any package where this class is visible.
● In other words, non-subclasses in other packages cannot
access protected members from other packages. Means,
this visibility control is strongly related to inheritance.
For example,
protected int val;
protected void display();
39. Default access/package access/friendly access
● The default access can also be called as package
access or friendly access.
● When no member accessibility modifier is
specified, the member is only accessible inside its
own package only.
● Even if its class is visible in another package, the
member is not accessible there.
● Default member accessibility is more restrictive
than the protected member accessibility.
41. Private access
● This is most restrictive than all other visibility controls.
● Private members are not accessible from any other class.
● They can not be accessed even from any subclass or
any class from the same package. In order to declare a
member as private, we just need to write ‘private’ in front
of the member as,
private int val;
private void display();
43. Arrays
● An array is contiguous or related data items that
share the common name.
● It offers the convenient means of grouping
information. This means that all elements in the
array have the same data type.
● A position in the array is indicated by a non-negative
integer value called as index.
● An element at the given position is accessed by
using this index.
● The size of array is fixed and can not increase to
accommodate more elements.
44. Types of array
● One dimensional array
● Multidimensional array
47. Array declaration
● One dimensional array is essentially, a list of
same-typed variables. A list of items can be
given one variable name using only one
subscript. The general form of creating one
dimensional array is,
datatype variablename[ ] = new datatype[size];
49. The strings
● In Java, a string is a sequence of characters. But, unlike
many other languages that implement strings as
character arrays, Java implements strings as objects of
type String.
● Implementing strings as built-in objects allows Java to
provide a full complement of features that make string
handling convenient.
● For example, Java has methods to compare two strings,
search for a substring, concatenate two strings, and
change the case of letters within a string.
● Also, String objects can be constructed a number of
ways, making it easy to obtain a string when needed.
50. Creating strings
● The String class has several constructors defined. To create an empty string
the default constructor is used. For example:
String s = new String();
● It will create the instance of the string with no characters in it. If we want to
initialize the string with values we can use following constructor.
String(char chars[])
● For example:
char chars[] = {‘h’, ‘e’, ‘l’, ‘l’, ‘o’};
String s = new String(chars);
53. Character at
String s = “Indian”;
char ch = s.charAt(2);
//ch will be ‘d’ after this
54. Equality
String a = “Hello”;
String b = “HELLO”;
if(a.equals(b)) //false
System.out.println(“Equals in case”);
if(a.equalsIgnoreCase(b))//true
System.out.println(“Equals in characters”);
55. String Buffer
● String represents fixed-length, immutable
character sequences.
● In contrast, StringBuffer represents growable
and writeable character sequences.
● It is possible to insert the characters anywhere
inside the StringBuffer.
● StringBuffer will automatically grow to make
room for such additions and often has more
characters pre-allocated than are actually
needed, to allow room for growth.
56. Creating StringBuffer
StringBuffer class defines three different
constructors:
StringBuffer()
StringBuffer(int size)
StringBuffer(String str)
57. How to use StringBuffer?
StringBuffer sb = new StringBuffer("Oriya");
int len = sb.length());
//len will be 5
int cap = sb.capacity());
//cap will be 21
58. Vector
● The package java.util contains a library of
Java’s utility classes.
● One of them is Vector class. It implements a
dynamic array which can hold the array of any
type and any number.
● These objects do not have to be homogenous.
Capacity of the Vector can be increased
automatically.
59. Creation of Vector
Vector class defines three different constructors:
Vector()
Vector(int size)
Vector(int size, int incr)
60. Operations of Vector
void addElement(Object element)
int capacity()
Object elementAt(int index)
int size()
boolean removeElement(Object element)
62. Wrapper classes
● The primitive data types of Java such as int, char,
float are not the part of any object hierarchy.
● They are always passed by value to the method not
by reference.
● Object representations of primitive data types are
called as wrapper classes.
● In essence, these classes encapsulate or wrap the
primitive data types within the class. All the wrapper
classes are defined in package java.lang.
63. Wrapper classes
Data type Wrapper class
boolean Boolean
char Character
double Double
float Float
int Integer
long Long
short Short
byte Byte
64. Example:
Character ch = new Character('X');
System.out.print("Char value: ");
System.out.println(ch.charValue());
if(Character.isDigit('0'))
System.out.println("0 is digit");
if(Character.isLowerCase('R'))
System.out.println("R is lower case");
65. Enumerated data type
● Enum is type like class and interface and can
be used to define a set of Enum constants.
● Enum constants are implicitly static and final
and you can not change there value once
created.
● Enum in Java provides type-safety and can be
used inside switch statment like int variables.
67. Inheritance
● Reusability is one of the most useful advantages of the Object
Oriented Programming.
● Reusability means using something again and again without creating
a new one.
● Java programming language supports this concept. The reusability
can be obtained by creating new classes and reusing the properties
of the existing one.
● The mechanism of deriving a new class from existing one is called
as inheritance.
● The old class or existing class is known as super class and new
class is known as subclass.
● Thus, a subclass is specialized version of super class. We can call
super class as base class or parent class and subclass as derived
class or child class.
68. Types of inheritance
● Single Inheritance (only one super and subclass)
● Multiple Inheritance (several super classes for a
subclass)
● Hierarchical Inheritance (one super class with many
subclasses)
● Multilevel Inheritance (subclass is super class of
another class)
● Hybrid Inheritance (combination of above three types)
69. Creating inheritance
The class can derived from another class by
following the syntax:
class subclassname extends superclassname
{
//Body of the class;
}
75. The 'super' keyword
● The keyword ‘super’ has specially been added
for inheritance.
● Whenever the subclass needs to refer to its
immediate super class, ‘super’ keyword is used.
There are two different applications of the
‘super’. That are,
– Accessing members from super class that has been
hidden by members of the subclass
– Calling super class constructor
76. Uses of 'super'
● Accessing members from super class
● In order to access the members from super class following form of the ‘super’ is used.
super.variablename;
● Calling super class constructor
● A subclass can call the constructor defined by super class by using the following form
of the ‘super’ keyword.
super(argumentlist);
● The argument list specifies any arguments needed by constructor in the super class.
Remember ‘super ( )’ must always be the first statement executed inside a subclass’
constructor.
77. Method overriding
● In a class hierarchy, when a method in a subclass has
the same name, same arguments and same return
type as a method in its super class, then the method
in the subclass is said to override the method in the
super class.
● When an overridden method is called from within a
subclass, it will always refer to the version of that
method defined by the subclass.
● The version of the method defined by the super class
will be hidden.
79. Dynamic method dispatch
● Dynamic method dispatch is the mechanism by which a
call to an overridden method is resolved at run time, rather
than compile time.
● Dynamic method dispatch is important because this is the
only way in which Java implements run-time
polymorphism.
● If a super class contains a method that is overridden by a
subclass, then when different types of objects are referred
to through super class reference variable, different
versions of the method are executed.
● This concept is C++ counterpart of Virtual function in
Java.
80. Example:
class Principal {
void message() {
System.out.println("This is Principal");
}
}
class Professor extends Principal {
void message() {
System.out.println("This is Professor");
}
}
class Lecturer extends Professor {
void message() {
System.out.println("This is Lecturer");
}
}
81. Example continued...
class Dynamic {
public static void main(String args[]) {
Principal x = new Principal();
Professor y = new Professor();
Lecturer z = new Lecturer();
Principal ref; //reference variable of super class
ref = x; //statement1
ref.message();
ref = y; //statement2
ref.message();
ref = z; //statement3
ref.message();
}
}
82. Abstract classes and methods
● Sometimes we will want to create a super class
that only defines a generalized form that will be
shared by all of its subclasses by leaving it to
each subclass to fill in the details.
● Such a class determines the nature of the
methods that the subclasses must implement.
This can be done by creating a class as an
abstract.
83. Abstract
● We can indicate that a method must always be
redefined in a subclass by making the
overriding compulsory.
● This can be achieved by preceding the keyword
‘abstract’ in the method definition with following
form:
abstract datatype methodname(parameters);
84. Abstract
abstract class White
{
……
abstract void paint();
……
……
}
● We can not create the objects of an abstract class. That is, an
abstract class cannot be directly instantiated with the new operator.
85. Application of 'final' in inheritance
● Prevent the method overriding
● Prevent the inheritance
86. Prevent method overriding
class First {
final void display() {
System.out.println(“This is first class”);
}
}
class Second extends First {
void display() {
System.out.println(“This is second class”);
}
}
error