0% found this document useful (0 votes)
2 views20 pages

Java Unit II Part I

The document outlines the concepts of Java programming related to packages and interfaces, detailing their definitions, advantages, and usage. It explains built-in and user-defined packages, access protection, and the process of importing packages, along with examples. Additionally, it covers the definition of interfaces, their characteristics, and their role in achieving abstraction and multiple inheritance in Java.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views20 pages

Java Unit II Part I

The document outlines the concepts of Java programming related to packages and interfaces, detailing their definitions, advantages, and usage. It explains built-in and user-defined packages, access protection, and the process of importing packages, along with examples. Additionally, it covers the definition of interfaces, their characteristics, and their role in achieving abstraction and multiple inheritance in Java.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JYOTHISHMATHI INSTITUTE OF TECHNOLOGY AND

SCIENCE
(Approved by AICTE, New Delhi and Affiliated to JNTU, Hyderabad)
KARMNAGAR - 505481
II [Link] II- Semester Java Programming (R18) 2021-22

II [Link] II- Semester


CS405PC
Java Programming (R18) 2021-22

UNIT-II PART-I

Prepared by [Link] Teja, Assistant Professor, CSE Dept Page 1


JYOTHISHMATHI INSTITUTE OF TECHNOLOGY AND
SCIENCE
(Approved by AICTE, New Delhi and Affiliated to JNTU, Hyderabad)
KARMNAGAR - 505481
II [Link] II- Semester Java Programming (R18) 2021-22

UNIT-II

Packages- Defining a Package, CLASSPATH, Access protection, importing packages.


Interfaces- defining an interface, implementing interfaces, Nested interfaces, applying
interfaces, variables in interfaces and extending interfaces.
Stream based I/O ([Link]) – The Stream classes-Byte streams and Character streams,
Reading console Input and Writing Console Output, File class, Reading and writing Files,
Random access file operations, The Console class, Serialization, Enumerations, auto boxing,
generics.

Packages

Java package is a mechanism of grouping similar type of classes, interfaces, and sub-classes
collectively based on functionality. When software is written in the Java programming
language, it can be composed of hundreds or even thousands of individual classes. It makes
sense to keep things organized by placing related classes and interfaces into packages.
Using packages while coding offers a lot of advantages like:
● Re-usability: The classes contained in the packages of another program can be
easily reused
● Name Conflicts: Packages help us to uniquely identify a class, for example, we can
have [Link] and [Link] classes
● Controlled Access: Offers access protection such as protected classes, default
classes and private class
● Data Encapsulation: They provide a way to hide classes, preventing other programs
from accessing classes that are meant for internal use only
● Maintainance: With packages, you can organize your project better and easily
locate related classes

In java, a package is a container of classes, interfaces, and sub-packages. We may think of it


as a folder in a file directory.

We use the packages to avoid naming conflicts and to organize project-related classes,
interfaces, and sub-packages into a bundle.

In java, the packages have divided into two types.

● Built-in Packages

Prepared by [Link] Teja, Assistant Professor, CSE Dept Page 2


JYOTHISHMATHI INSTITUTE OF TECHNOLOGY AND
SCIENCE
(Approved by AICTE, New Delhi and Affiliated to JNTU, Hyderabad)
KARMNAGAR - 505481
II [Link] II- Semester Java Programming (R18) 2021-22
● User-defined Packages

Built-in Packages
The built-in packages are the packages from java API. The Java API is a library of
pre-defined classes, interfaces, and sub-packages. The built-in packages were included in
the JDK.
There are many built-in packages in java, few of them are as java, lang, io, util, awt, javax,
swing, net, sql, etc.

We need to import the built-in packages to use them in our program. To import a package,
we use the import statement.

All Java predefine classes are distributed into several different package.

Some package are


1. lang Package: Lang stands for language. This package contains those class which are
essential for every java program.

E.g. String and System class

Lang is the default package of java which means it is optional to import Lang package
in program

Syntax of Import package:-

import [package name].*; // (all class)


import [package name].[class name];//(Single class)

2. io package: io stands for input/output. This package contains those class which are
essential for input and output. Some classes of input/output package are;

E.g. – DataInputStream, BufferReader, DataInoutStramReader

3. util package: util stands for utility package this package contain different type of
classes related to various task.

E.g.: Date, time, calendar, array, vector. Array List etc.

4. awt package (swing): awt stands for abstract windowing tool. With the help of this
package we can create GUI interface. This package provide many GUI tools.

Prepared by [Link] Teja, Assistant Professor, CSE Dept Page 3


JYOTHISHMATHI INSTITUTE OF TECHNOLOGY AND
SCIENCE
(Approved by AICTE, New Delhi and Affiliated to JNTU, Hyderabad)
KARMNAGAR - 505481
II [Link] II- Semester Java Programming (R18) 2021-22
E.g.: Command button, choice, list, radio, etc.
awt contain a sub package name “even”.

5. applet: with the help of applet function we can create a java program which can be
embedded into HTML page by which web browser execute the java program. Web
browser must be java enabled.

6. Sql Package: sql stands for structure query language. This package provides a
complete range of classes which is needed for jdbc (java database connectivity). Some
important classes of sql package are:

E.g.: connection, ResultSet, PrepareStatement, etc.

7. Net package: net stands for networking. This package contains classes to implement or
create connection between two or more systems or if we want to implement client
server approach then. We can use the classes of net package.

E.g.: TCP/IP, Request, etc.

User-defined Packages
The user-defined packages are the packages created by the user. User is free to create their
own packages.

Definig a Package in java


We use the package keyword to create or define a package in java programming language.

Syntax:
package packageName;

Note:
● The package statement must be the first statement in the program.
● The package name must be a single word.

Let's consider the following code to create a user-defined package myPackage.

Example:
package jitsPackage;
public class DefiningJitsPackage {
public static void main(String[] args) {
[Link]("This class belongs to jitsPackage.");
}

Prepared by [Link] Teja, Assistant Professor, CSE Dept Page 4


JYOTHISHMATHI INSTITUTE OF TECHNOLOGY AND
SCIENCE
(Approved by AICTE, New Delhi and Affiliated to JNTU, Hyderabad)
KARMNAGAR - 505481
II [Link] II- Semester Java Programming (R18) 2021-22
}

Now, save the above code in a file [Link], and compile it using the
following command.
javac -d . [Link]

The -d switch specifies the destination where to put the generated class file. You can use any
directory name like /home (in case of Linux), d:/abc (in case of windows) etc. If you want to
keep the package within the same directory, you can use . (dot).

The above command creates a directory with the package name jitsPackage, and the
[Link] is saved into it.
Run the program use the following command.

C:\javaclass>java [Link]
Output:
This class belongs to jitsPackage.

When we use IDE like Eclipse, Netbeans, etc. the package structure is created automatically.

Access protection in java packages

In java, the access modifiers define the accessibility of the class and its members. For
example, private members are accessible within the same class members only. Java has four
access modifiers, and they are default, private, protected, and public.

In java, the package is a container of classes, sub-classes, interfaces, and sub-packages. The
class acts as a container of data and methods. So, the access modifier decides the
accessibility of class members across the different packages.

In java, the accessibility of the members of a class or interface depends on its access
specifiers. The following table provides information about the visibility of both data
members and methods.

Prepared by [Link] Teja, Assistant Professor, CSE Dept Page 5


JYOTHISHMATHI INSTITUTE OF TECHNOLOGY AND
SCIENCE
(Approved by AICTE, New Delhi and Affiliated to JNTU, Hyderabad)
KARMNAGAR - 505481
II [Link] II- Semester Java Programming (R18) 2021-22

Note:
● The public members can be accessed everywhere.
● The private members can be accessed only inside the same class.
● The protected members are accessible to every child class (same package or other
packages).
● The default members are accessible within the same package but not outside the
package.

Importing Packages in java


In java, the import keyword used to import built-in and user-defined packages. When a
package has imported, we can refer to all the classes of that package using their name
directly.

The import statement must be after the package statement, and before any other statement.

Using an import statement, we may import a specific class or all the classes from a package.
● Using one import statement, we may import only one package or a class.
● Using an import statement, we cannot import a class directly, but it must be a part of a
package.
● A program may contain any number of import statements.

Importing specific class


Using an importing statement, we can import a specific class. The following syntax is
employed to import a specific class.

Syntax

Prepared by [Link] Teja, Assistant Professor, CSE Dept Page 6


JYOTHISHMATHI INSTITUTE OF TECHNOLOGY AND
SCIENCE
(Approved by AICTE, New Delhi and Affiliated to JNTU, Hyderabad)
KARMNAGAR - 505481
II [Link] II- Semester Java Programming (R18) 2021-22
import [Link];

Let's look at an import statement to import a built-in package and Scanner class.

Example:
package jitsPackage;

import [Link];
public class ImportingExample {
public static void main(String[] args) {
Scanner read = new Scanner([Link]);
int i = [Link]();
[Link]("You have entered a number " + i);
}
}
In the above code, the class ImportingExample belongs to jitsPackage package, and it also
importing a class called Scanner from [Link] package.

Importing all the classes


Using an importing statement, we can import all the classes of a package. To import all the
classes of the package, we use * symbol. The following syntax is employed to import all the
classes of a package.

Syntax
import packageName.*;
Example:
package jitsPackage;

import [Link].*;

public class ImportingExample {


public static void main(String[] args) {
Scanner read = new Scanner([Link]);
int i = [Link]();
[Link]("You have entered a number " + i);

Random rand = new Random();


int num = [Link](100);
[Link]("Randomly generated number " + num);
}
}
Prepared by [Link] Teja, Assistant Professor, CSE Dept Page 7
JYOTHISHMATHI INSTITUTE OF TECHNOLOGY AND
SCIENCE
(Approved by AICTE, New Delhi and Affiliated to JNTU, Hyderabad)
KARMNAGAR - 505481
II [Link] II- Semester Java Programming (R18) 2021-22

In the above code, the class ImportingExample belongs to jitsPackage package, and it also
importing all the classes like Scanner, Random, Stack, Vector, ArrayList, HashSet, etc. from
the [Link] package.

Note:
● The import statement imports only classes of the package, but not sub-packages and
its classes.
● We may also import sub-packages by using a symbol '.' (dot) to separate parent
package and sub-package.

Consider the following import statement.


import [Link].*;

The above import statement util is a sub-package of java package. It imports all the classes
of util package only, but not classes of java package.

Including a Class in Java Package


To create a class inside a package, you should declare the package name as the first
statement of your program. Then include the class as part of the package. But, remember
that, a class can have only one package declaration. Here’s a simple program to understand
the concept.

Example:
package jitsPackage;

public class Compare {


int num1, num2;

public Compare(int n, int m) {


num1 = n;
num2 = m;
}
public void getmax(){
if ( num1 > num2 ) {
[Link]("Maximum value of two numbers is " + num1);
}
else {
[Link]("Maximum value of two numbers is " + num2);
}
}
Prepared by [Link] Teja, Assistant Professor, CSE Dept Page 8
JYOTHISHMATHI INSTITUTE OF TECHNOLOGY AND
SCIENCE
(Approved by AICTE, New Delhi and Affiliated to JNTU, Hyderabad)
KARMNAGAR - 505481
II [Link] II- Semester Java Programming (R18) 2021-22

public static void main(String args[]) {


Compare current[] = new Compare[3];

current[1] = new Compare(5, 10);


current[2] = new Compare(123, 120);

for(int i=1; i < 3 ; i++)


{
current[i].getmax();
}
}
}

Output:
C:\javaclass>javac -d . [Link]

this program would be saved in a file as [Link] and will be stored in the directory
named jitsPackage. When the file gets compiled, Java will create a .class file and store it in
the same directory. Remember that name of the package must be same as the directory under
which this file is saved.

You might be wondering how to use this Compare class from a class in another package?

Creating a class inside package while importing another package


Well, it’s quite simple. You just need to import it. Once it is imported, you can access it by
its name. Here’s a sample program demonstrating the concept.

[Link]

import [Link];

public class DemoPackage{


public static void main(String args[]) {
int n=10, m=10; // n=11,m=10
Compare current = new Compare(n, m);
if(n != m) {
[Link]();
}
Prepared by [Link] Teja, Assistant Professor, CSE Dept Page 9
JYOTHISHMATHI INSTITUTE OF TECHNOLOGY AND
SCIENCE
(Approved by AICTE, New Delhi and Affiliated to JNTU, Hyderabad)
KARMNAGAR - 505481
II [Link] II- Semester Java Programming (R18) 2021-22
else {
[Link]("Both the values are same");
}
}
}

Output:
C:\javaclass>javac [Link]

C:\javaclass>java DemoPackage
Both the values are same

C:\javaclass>java DemoPackage
Maximum value of two numbers is 11

Defining an interface in java

In java, an interface is similar to a class, but it contains abstract methods and static final
variables only. (Or) An interface in Java is a blueprint of a class. It has static constants
and abstract methods. The interface in Java is another mechanism to achieve abstraction.

We may think of an interface as a completely abstract class. None of the methods in the
interface has an implementation, and all the variables in the interface are constants.

All the methods of an interface, implemented by the class that implements it.

The interface in java enables java to support multiple-inheritance. An interface may extend
only one interface, but a class may implement any number of interfaces.

It cannot be instantiated just like the abstract class.


Since Java 8, we can have default and static methods in an interface.

Since Java 9, we can have private methods in an interface.

Why use Java interface?


There are mainly three reasons to use interface. They are given below.

✔ It is used to achieve abstraction.


✔ By interface, we can support the functionality of multiple inheritance.
✔ It can be used to achieve loose coupling.

Note:
Prepared by [Link] Teja, Assistant Professor, CSE Dept Page 10
JYOTHISHMATHI INSTITUTE OF TECHNOLOGY AND
SCIENCE
(Approved by AICTE, New Delhi and Affiliated to JNTU, Hyderabad)
KARMNAGAR - 505481
II [Link] II- Semester Java Programming (R18) 2021-22
● An interface is a container of abstract methods and static final variables.
● An interface, implemented by a class. (class implements interface).
● An interface may extend another interface. (Interface extends Interface).
● An interface never implements another interface, or class.
● A class may implement any number of interfaces.
● We cannot instantiate an interface.
● Specifying the keyword abstract for interface methods is optional, it automatically
added.
● All the members of an interface are public by default.

How to declare an interface?

An interface is declared by using the interface keyword. It provides total abstraction; means
all the methods in an interface are declared with the empty body, and all the fields are
public, static and final by default. A class that implements an interface must implement all
the methods declared in the interface.

Syntax:
interface <interface_name>{
// declare constant fields
// declare methods that abstract by default.
}

Note:
The Java compiler adds public and abstract keywords before the interface method.
Moreover, it adds public, static and final keywords before data members.

In other words, Interface fields are public, static and final by default, and the methods are
public and abstract.

Every interface in Java is auto-completed by the compiler. For example, in the above
example code, no member is defined as public, but all are public automatically.

The relationship between classes and interfaces

Prepared by [Link] Teja, Assistant Professor, CSE Dept Page 11


JYOTHISHMATHI INSTITUTE OF TECHNOLOGY AND
SCIENCE
(Approved by AICTE, New Delhi and Affiliated to JNTU, Hyderabad)
KARMNAGAR - 505481
II [Link] II- Semester Java Programming (R18) 2021-22
As shown in the figure given below, a class extends another class, an interface extends
another interface, but a class implements an interface.

Implementing an Interface in java


In java, an interface is implemented by a class. The class that implements an interface must
provide code for all the methods defined in the interface, otherwise, it must be defined as an
abstract class.
The class uses a keyword implements to implement an interface. A class can implement any
number of interfaces. When a class wants to implement more than one interface, we use
the implements keyword is followed by a comma-separated list of the interfaces
implemented by the class.
The following is the syntax for defineing a class that implements an interface.

Syntax
class className implements InterfaceName{
...
body-of-the-class
...
}

Let's look at an example code to define a class that implements an interface.

Example
interface Human {

void learn(String str);


void work();

int duration = 10;


}

Prepared by [Link] Teja, Assistant Professor, CSE Dept Page 12


JYOTHISHMATHI INSTITUTE OF TECHNOLOGY AND
SCIENCE
(Approved by AICTE, New Delhi and Affiliated to JNTU, Hyderabad)
KARMNAGAR - 505481
II [Link] II- Semester Java Programming (R18) 2021-22

class Programmer implements Human{


public void learn(String str) {
[Link]("Learn using Java " + str);
}
public void work() {
[Link]("Develop Java applications");
}
}

public class HumanTest {

public static void main(String[] args) {


Programmer trainee = new Programmer();
[Link]("coding");
[Link]();
}
}
Output:
Learn using Java coding
Develop Java applications

In the above code defines an interface Human that contains two abstract methods learn(),
work() and one constant duration. The class Programmer implements the interface. As it
implementing the Human interface it must provide the body of all the methods those defined
in the Human interface.

Implementing multiple Interfaces

When a class wants to implement more than one interface, we use the implements keyword
is followed by a comma-separated list of the interfaces implemented by the class.

The following is the syntax for defining a class that implements multiple interfaces.

Syntax

class className implements InterfaceName1, InterfaceName2, ...{


...
boby-of-the-class
...

Prepared by [Link] Teja, Assistant Professor, CSE Dept Page 13


JYOTHISHMATHI INSTITUTE OF TECHNOLOGY AND
SCIENCE
(Approved by AICTE, New Delhi and Affiliated to JNTU, Hyderabad)
KARMNAGAR - 505481
II [Link] II- Semester Java Programming (R18) 2021-22
}

Let's look at an example code to define a class that implements multiple interfaces.

Example:
interface Human {
void learn(String str);
void work();
}
interface Recruitment {
boolean screening(int score);
boolean interview(boolean selected);
}
class Programmer implements Human, Recruitment {
public void learn(String str) {
[Link]("Learn using " + str);
}
public boolean screening(int score) {
[Link]("Attend screening test");
int thresold = 20;
if(score > thresold)
return true;
return false;
}
public boolean interview(boolean selected) {
[Link]("Attend interview");
if(selected)
return true;
return false;
}
public void work() {
[Link]("Develop applications");
}
}
public class HumanTest2Int {
public static void main(String[] args) {
Programmer trainee = new Programmer();
[Link]("Coding");
[Link](30);
[Link](true);
[Link]();
Prepared by [Link] Teja, Assistant Professor, CSE Dept Page 14
JYOTHISHMATHI INSTITUTE OF TECHNOLOGY AND
SCIENCE
(Approved by AICTE, New Delhi and Affiliated to JNTU, Hyderabad)
KARMNAGAR - 505481
II [Link] II- Semester Java Programming (R18) 2021-22
}
}

Output:
Learn using Coding
Attend screening test
Attend interview
Develop applications

In the above code defines two interfaces Human and Recruitment, and a class Programmer
implements both the interfaces.

Nested Interfaces in java


In java, an interface may be defined inside another interface, and also inside a class. The
interface that defined inside another interface or a class is known as nested interface. The
nested interface is also referred as inner interface.

● The nested interface declared within an interface is public by default.


● The nested interface declared within a class can be with any access modifier.
● Every nested interface is static by default.

The nested interface cannot be accessed directly. We can only access the nested interface by
using outer interface or outer class name followed by dot( . ), followed by the nested
interface name.

Nested interface inside another interface

The nested interface that defined inside another interface must be accessed
as [Link].

Let's look at an example code to illustrate nested interfaces inside another interface.

Example
interface OuterInterface{
void outerMethod();

interface InnerInterface{
void innerMethod();
}
}

Prepared by [Link] Teja, Assistant Professor, CSE Dept Page 15


JYOTHISHMATHI INSTITUTE OF TECHNOLOGY AND
SCIENCE
(Approved by AICTE, New Delhi and Affiliated to JNTU, Hyderabad)
KARMNAGAR - 505481
II [Link] II- Semester Java Programming (R18) 2021-22
class OnlyOuter implements OuterInterface{
public void outerMethod() {
[Link]("This is OuterInterface method");
}
}

class OnlyInner implements [Link]{


public void innerMethod() {
[Link]("This is InnerInterface method");
}
}

public class NestedInterfaceExample {

public static void main(String[] args) {


OnlyOuter obj_1 = new OnlyOuter();
OnlyInner obj_2 = new OnlyInner();

obj_1.outerMethod();
obj_2.innerMethod();
}

Output:

This is OuterInterface method


This is InnerInterface method

Nested interface inside a class


The nested interface that defined inside a class must be accessed
as [Link].
Let's look at an example code to illustrate nested interfaces inside a class.

Example
class OuterClass{

interface InnerInterface{
void innerMethod();
}

Prepared by [Link] Teja, Assistant Professor, CSE Dept Page 16


JYOTHISHMATHI INSTITUTE OF TECHNOLOGY AND
SCIENCE
(Approved by AICTE, New Delhi and Affiliated to JNTU, Hyderabad)
KARMNAGAR - 505481
II [Link] II- Semester Java Programming (R18) 2021-22
}

class ImplementingClass implements [Link]{


public void innerMethod() {
[Link]("This is InnerInterface method");
}
}

public class NestedInterface {

public static void main(String[] args) {


ImplementingClass obj = new ImplementingClass();

[Link]();
}

}
Output:
This is InnerInterface method

Nested interface inside another interface


The nested interface that defined inside another interface must be accessed as
[Link].

Example:
interface Printable{
void print();
}
interface Showable{
void show();
}
Prepared by [Link] Teja, Assistant Professor, CSE Dept Page 17
JYOTHISHMATHI INSTITUTE OF TECHNOLOGY AND
SCIENCE
(Approved by AICTE, New Delhi and Affiliated to JNTU, Hyderabad)
KARMNAGAR - 505481
II [Link] II- Semester Java Programming (R18) 2021-22
class ImMultInh implements Printable,Showable{
public void print(){[Link]("Hello");}
public void show(){[Link]("Welcome");}

public static void main(String args[]){


ImMultInh obj = new ImMultInh();
[Link]();
[Link]();
}
}
Output:
Hello
Welcome

Variables in Java Interfaces


In java, an interface is a completely abstract class. An interface is a container of abstract
methods and static final variables. The interface contains the static final variables. The
variables defined in an interface cannot be modified by the class that implements the
interface, but it may use as it defined in the interface.

✔ The variable in an interface is public, static, and final by default.


✔ If any variable in an interface is defined without public, static, and final keywords
then, the compiler automatically adds the same.
✔ No access modifier is allowed except the public for interface variables.
✔ Every variable of an interface must be initialized in the interface itself.
✔ The class that implements an interface cannot modify the interface variable, but it
may use as it defined in the interface.

Example:
interface SampleInterface{
int UPPER_LIMIT = 100;
//int LOWER_LIMIT; // Error - must be initialised
}

public class InterfaceVariablesExample implements SampleInterface{


public static void main(String[] args) {
[Link]("UPPER LIMIT = " + UPPER_LIMIT);
// UPPER_LIMIT = 150; // Can not be modified
}
}
Output:
Prepared by [Link] Teja, Assistant Professor, CSE Dept Page 18
JYOTHISHMATHI INSTITUTE OF TECHNOLOGY AND
SCIENCE
(Approved by AICTE, New Delhi and Affiliated to JNTU, Hyderabad)
KARMNAGAR - 505481
II [Link] II- Semester Java Programming (R18) 2021-22
UPPER LIMIT = 100

Extending an Interface in java


In java, an interface can extend another interface. When an interface wants to extend another
interface, it uses the keyword extends. The interface that extends another interface has its
own members and all the members defined in its parent interface too. The class which
implements a child interface needs to provide code for the methods defined in both child
and parent interfaces, otherwise, it needs to be defined as abstract class.

✔ An interface can extend another interface.


✔ An interface cannot extend multiple interfaces.
✔ An interface can implement neither an interface nor a class.
✔ The class that implements child interface needs to provide code for all the methods
defined in both child and parent interfaces.

Example
interface ParentInterface{
void parentMethod();
}

interface ChildInterface extends ParentInterface{


void childMethod();
}

class ImplementingClass implements ChildInterface{


public void childMethod() {
[Link]("Child Interface method!!");
}

public void parentMethod() {


[Link]("Parent Interface mehtod!");
}
}

public class ExtendingAnInterface {


public static void main(String[] args) {
ImplementingClass obj = new ImplementingClass();
[Link]();
[Link]();
}
}
Prepared by [Link] Teja, Assistant Professor, CSE Dept Page 19
JYOTHISHMATHI INSTITUTE OF TECHNOLOGY AND
SCIENCE
(Approved by AICTE, New Delhi and Affiliated to JNTU, Hyderabad)
KARMNAGAR - 505481
II [Link] II- Semester Java Programming (R18) 2021-22
Output:
Child Interface method!!
Parent Interface method!

Prepared by [Link] Teja, Assistant Professor, CSE Dept Page 20

You might also like