Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
assignments_new
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gopi Ayinala Ayinala
assignments_new
Commits
64bd516f
Commit
64bd516f
authored
Jun 28, 2022
by
Suresh Kumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Inheritance
parent
6c965654
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
246 additions
and
0 deletions
+246
-0
Priority.java
Inheritance/src/MultipleInterface/com/Priority.java
+29
-0
Address.java
Inheritance/src/aggregation/com/Address.java
+13
-0
Aggregat.java
Inheritance/src/aggregation/com/Aggregat.java
+11
-0
Employee.java
Inheritance/src/aggregation/com/Employee.java
+26
-0
Addres.java
Inheritance/src/association/com/Addres.java
+16
-0
Associat.java
Inheritance/src/association/com/Associat.java
+15
-0
Person.java
Inheritance/src/association/com/Person.java
+23
-0
Car.java
Inheritance/src/composition/com/Car.java
+16
-0
Compos.java
Inheritance/src/composition/com/Compos.java
+14
-0
Engine.java
Inheritance/src/composition/com/Engine.java
+21
-0
Hierarchical.java
Inheritance/src/inheritancetype/Hierarchical.java
+25
-0
Multilevel.java
Inheritance/src/inheritancetype/Multilevel.java
+20
-0
Single.java
Inheritance/src/inheritancetype/Single.java
+17
-0
No files found.
Inheritance/src/MultipleInterface/com/Priority.java
0 → 100644
View file @
64bd516f
package
MultipleInterface
.
com
;
interface
Printable
{
default
public
void
showdata
(){
System
.
out
.
println
(
"Hi I Am Method Of Printable Interface"
);
}
}
interface
Showable
{
default
public
void
showdata
(){
System
.
out
.
println
(
"Hi I am Method of Showable Interfae "
);
}
}
public
class
Priority
implements
Printable
,
Showable
{
public
static
void
main
(
String
[]
args
){
Printable
printable
=
new
Priority
();
Showable
showable
=
new
Priority
();
// printable.showdata();
showable
.
showdata
();
}
public
void
showdata
(){
Showable
.
super
.
showdata
();
}
}
Inheritance/src/aggregation/com/Address.java
0 → 100644
View file @
64bd516f
package
aggregation
.
com
;
public
class
Address
{
int
hno
;
String
city
;
String
country
;
Address
(
int
h
,
String
c
,
String
cntry
){
this
.
hno
=
h
;
this
.
city
=
c
;
this
.
country
=
cntry
;
}
}
Inheritance/src/aggregation/com/Aggregat.java
0 → 100644
View file @
64bd516f
package
aggregation
.
com
;
public
class
Aggregat
{
public
static
void
main
(
String
[]
args
){
Address
adOjb
=
new
Address
(
150
,
"Umerkot"
,
"Pakistan"
);
Employee
emp1
=
new
Employee
(
1
,
"Suresh"
,
adOjb
);
emp1
.
display
();
}
}
Inheritance/src/aggregation/com/Employee.java
0 → 100644
View file @
64bd516f
package
aggregation
.
com
;
public
class
Employee
{
int
id
;
String
name
;
Address
add
;
Employee
(
int
i
,
String
n
,
Address
a
){
this
.
id
=
i
;
this
.
name
=
n
;
this
.
add
=
a
;
}
void
display
(){
System
.
out
.
println
(
"Your Id Number is .................. ("
+
id
+
")\n"
+
"Your Name is .........................("
+
name
+
")\n"
+
"Your House _No Is ...........................("
+
add
.
hno
+
")\n"
+
"Your City Name is................................("
+
add
.
city
+
")\n"
+
"your Country Name is..................................("
+
add
.
country
+
") \n "
);
System
.
out
.
print
(
"------------------------Composition With Aggregation------------------------"
);
}
}
Inheritance/src/association/com/Addres.java
0 → 100644
View file @
64bd516f
package
association
.
com
;
public
class
Addres
{
int
hno
;
int
zip
;
String
city
;
String
country
;
Addres
(
int
hno
,
int
zip
,
String
city
,
String
country
){
this
.
hno
=
hno
;
this
.
zip
=
zip
;
this
.
city
=
city
;
this
.
country
=
country
;
}
}
Inheritance/src/association/com/Associat.java
0 → 100644
View file @
64bd516f
package
association
.
com
;
public
class
Associat
{
public
static
void
main
(
String
[]
args
){
Addres
add
=
new
Addres
(
152
,
15334
,
"Umerkot Sindh"
,
"Pakistan"
);
Person
emp1
=
new
Person
(
"Suresh Kumar"
,
add
);
emp1
.
display
();
}
}
Inheritance/src/association/com/Person.java
0 → 100644
View file @
64bd516f
package
association
.
com
;
public
class
Person
{
String
name
;
Addres
add
;
Person
(
String
name
,
Addres
add
){
this
.
name
=
name
;
this
.
add
=
add
;
}
void
display
(){
System
.
out
.
println
(
"Your Name Name is Mr........ ("
+
name
+
")\n"
+
"Your House No is .........................("
+
add
.
hno
+
")\n"
+
"Your Zip Code is ...........................("
+
add
.
zip
+
")\n"
+
"Your City Name is...........................("
+
add
.
city
+
")\n"
+
"your Country Name is..................................("
+
add
.
country
+
") \n "
);
System
.
out
.
print
(
"------------------------Compositin With Association-------------------------"
);
}
}
Inheritance/src/composition/com/Car.java
0 → 100644
View file @
64bd516f
package
composition
.
com
;
public
class
Car
{
private
final
String
name
;
private
final
Engine
engine
;
public
Car
(
String
name
,
Engine
engine
){
this
.
name
=
name
;
this
.
engine
=
engine
;
}
public
String
getName
(){
return
name
;
}
public
Engine
getEngine
(){
return
engine
;
}
}
Inheritance/src/composition/com/Compos.java
0 → 100644
View file @
64bd516f
package
composition
.
com
;
public
class
Compos
{
public
static
void
main
(
String
[]
args
){
Engine
engn
=
new
Engine
(
"Petrol"
,
500
);
Car
cr
=
new
Car
(
"Fortuner"
,
engn
);
System
.
out
.
println
(
"Name Of Vehicle............("
+
cr
.
getName
()
+
")\n"
+
"Of engine is.....................("
+
engn
.
getType
()
+
")\n"
+
"HorsePower Of Engine..................("
+
engn
.
getHp
()
+
")\n"
);
System
.
out
.
println
(
"--------------------Composition---------------------"
);
}
}
Inheritance/src/composition/com/Engine.java
0 → 100644
View file @
64bd516f
package
composition
.
com
;
public
class
Engine
{
private
String
type
;
private
int
hp
;
Engine
(
String
type
,
int
hp
){
this
.
type
=
type
;
this
.
hp
=
hp
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
String
getType
()
{
return
type
;
}
public
void
setHp
(
int
hp
)
{
this
.
hp
=
hp
;
}
public
int
getHp
()
{
return
hp
;
}
}
Inheritance/src/inheritancetype/Hierarchical.java
0 → 100644
View file @
64bd516f
package
inheritancetype
;
class
Parent
{
void
eat
(){
System
.
out
.
println
(
"Eating.........."
);
};
}
class
Child_1
extends
Parent
{
void
name_1
(){
System
.
out
.
println
(
"Hi I am Child_1........"
);
}
}
class
Child_2
extends
Parent
{
void
name_2
(){
System
.
out
.
println
(
"Hi I am Child_2..........."
);
}
}
public
class
Hierarchical
{
public
static
void
main
(
String
[]
args
){
Child_2
ch
=
new
Child_2
();
ch
.
eat
();
ch
.
name_2
();
System
.
out
.
println
(
"Hierarchical Inheritance ................"
);
}
}
Inheritance/src/inheritancetype/Multilevel.java
0 → 100644
View file @
64bd516f
package
inheritancetype
;
class
GrandFather
{
void
drink
(){
System
.
out
.
println
(
"Drinking.."
);}
}
class
Father
extends
GrandFather
{
void
eat
(){
System
.
out
.
println
(
"Eating..."
);}
}
class
Son
extends
Father
{
void
speak
(){
System
.
out
.
println
(
"Speaking..."
);}
}
public
class
Multilevel
{
public
static
void
main
(
String
[]
args
){
Son
b
=
new
Son
();
b
.
drink
();
b
.
eat
();
b
.
speak
();
System
.
out
.
println
(
"Hi This is Multi Level Inheritance"
);
}
}
\ No newline at end of file
Inheritance/src/inheritancetype/Single.java
0 → 100644
View file @
64bd516f
package
inheritancetype
;
class
Animal
{
void
drink
(){
System
.
out
.
println
(
"Drinking.."
);}
}
class
Dog
extends
Animal
{
void
bark
(){
System
.
out
.
println
(
"Barking..."
);}
}
public
class
Single
{
public
static
void
main
(
String
[]
args
){
Dog
d
=
new
Dog
();
d
.
bark
();
d
.
drink
();
System
.
out
.
println
(
"Hi This is Single Level Inheritance"
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment