0% found this document useful (0 votes)
19 views11 pages

Hlo 41

The document discusses InnerInterfaces and InnerAbstractClasses in Java, detailing their declarations within classes, interfaces, and abstract classes. It provides examples of each type of inner interface and class, along with a brief overview of encapsulation and exception handling processes in Java. Additionally, it outlines the components of Java programming, including variables, methods, blocks, constructors, classes, interfaces, and abstract classes.

Uploaded by

MONICA NAHAK
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)
19 views11 pages

Hlo 41

The document discusses InnerInterfaces and InnerAbstractClasses in Java, detailing their declarations within classes, interfaces, and abstract classes. It provides examples of each type of inner interface and class, along with a brief overview of encapsulation and exception handling processes in Java. Additionally, it outlines the components of Java programming, including variables, methods, blocks, constructors, classes, interfaces, and abstract classes.

Uploaded by

MONICA NAHAK
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
You are on page 1/ 11

Dt : 6/9/2023

*imp

InnerInterfaces in Java:

(i)InnerInterfaces in Classes:

ii
=>we can also declare InnerInterfaces in Classes and which can be

ath
Static member InnerInterfaces or NonStatic member InnerInterfaces.

(ii)InnerInterfaces in Interfaces:(Nested Interfaces)

aip
=>we can also declare InnerInterfaces in Interfaces and which are

automatically static member InnerInterfaces.


hM
(iii)InnerInterfaces in AbstractClasses:

=>we can also declare InnerInterfaces in AbstractClasses and which

can be static member InnerInterfaces or NonStatic member


tes

InnerInterfaces
a
nk

Ex:

ProjectName : App_InnerInterfaces
Ve

packages,

p1 : SubClass.java
package p1;
public class SubClass
{
public interface ITest1
{
public abstract void m1(int a);
}//Instance member InnerInterface
public static interface ITest11
{
public abstract void m11(int b);
}//Static member InnerInterface
}//OuterClass

p1 : ITest.java

ii
package p1;

ath
public interface ITest
{
public static interface ITest2

aip
{
public abstract void m2(int c);
}//Static member InnerInterface
}//OuterInterface
hM
p1 : AClass.java
package p1;
tes

public abstract class AClass


{
public interface ITest3
{
a

public abstract void m3(int d);


nk

}//Instance member InnerInterface


public static interface ITest33
{
Ve

public abstract void m33(int e);


}//Static member InnerInterface
}//OuterAbstractClass

p2 : DemoInnerInterfaces.java(MainClass)
package p2;
import p1.*;
public class DemoInnerInterfaces
{
public static void main(String[] args)
{
System.out.println("****InnerInterfac in
Class*****");
SubClass.ITest1 ob1 = (int a)->
{
System.out.println("---m1(a)---");
System.out.println("The value a:"+a);

ii
};

ath
SubClass.ITest11 ob11 = (int b)->
{
System.out.println("---m11(b)---");
System.out.println("The value b:"+b);

aip
};
ob1.m1(11);
ob11.m11(12);
System.out.println("****InnerInterface in
hM
Interface****");
ITest.ITest2 ob2 = (int c)->
{
System.out.println("---m2(c)---");
System.out.println("The value c:"+c);
tes

};
ob2.m2(13);
System.out.println("****InnerInterfaces in
a

AbstractClasses****");
AClass.ITest3 ob3 = (int d)->
nk

{
System.out.println("---m3(d)---");
System.out.println("The value d:"+d);
Ve

};
AClass.ITest33 ob33 = (int e)->
{
System.out.println("---m33(e)---");
System.out.println("The value e:"+e);
};
ob3.m3(15);
ob33.m33(16);
}

o/p:

****InnerInterfac in Class*****

ii
---m1(a)---

ath
The value a:11

---m11(b)---

aip
The value b:12

****InnerInterface in Interface****
hM
---m2(c)---

The value c:13

****InnerInterfaces in AbstractClasses****
tes

---m3(d)---

The value d:15


a
nk

---m33(e)---

The value e:16


Ve

==============================================================

*imp

InnerAbstractClasses in Java:

(i)InnerAbstractClasses in Classes:

=>we can also declare InnerAbstractClasses in Classes and which


can be static member InnerAbstractClasses or NonStatic member

InnerAbstractClasses.

(ii)InnerAbstractClasses in Interfaces:

=>We can also declare InnerAbstractClasses in Interfaces and which

are automatically Static member InnerAbstractClasses.

ii
(iii)InnerAbstractClasses in AbstractClasses:(Nested AbstractClasses)

ath
=>we can also declare InnerAbstractClasses in AbstractClasses and

which can be static member InnerAbstractClasses or NonStatic

aip
member InnerAbstractClasses.
hM
Ex:(Assognment)

===============================================================

faq:
tes

define Encapsulation process?

=>The process of binding all the programming components into a single


a
nk

unit class is known as "Encapsulation process".


Ve

=>Class can hold Variables,Concrete methods,Blocks,Constructors,

InnerClasses,InnerInterafces and InnerAbstractClasses.

=>Interface can hold Variables,Abstract methods,Concrete methods,

InnerClasses,InnerInterfaces and InnerAbstractClasses

=>AbstractClass can hold variables,Abstract methods,Concrete methods,


Blocks,Constructors,InnerClasses,InnerInterfaces and InnerAbstract

Classes.

Diagram:

ii
ath
aip
hM
tes

===================================================================
==
a

Summary of Programming Components:(Java Alphabets)


nk

(a)variables
Ve

1.Primitive datatype variables(Values)

(i)Static Variables

(ii)NonStatic Variables

=>Instance Variables

=>Local Variables
2.NonPrimitive datatype variables(Object references)

(i)Static Variables

(ii)NonStatic Variables

=>Instance Variables

=>Local Variables

ii
---------------------------------------------------------

ath
(b)Methods

1.Static methods

aip
2.NonStatic methods(Instance methods)

--------------------------------------------------------------
hM
(c)Blocks

1.static blocks

2.NonStatic blocks(Instance blocks)


tes

-----------------------------------------------------

(d)Constructors
a
nk

=>NonStatic Constructors

(There is no Concept of Static Constructors in Java)


Ve

-----------------------------------------------------

(e)Classes

1.static classes(Only as InnerClasses)

2.NonStatic Classes

----------------------------------------------------
(f)Interfaces

1.static Interfaces(Only as InnerInterfaces)

2.NonStatic Interfaces

---------------------------------------------------

(g)AbstractClasses

ii
1.static AbstractClasses(Only as InnerAbstractClasses)

ath
2.NonStatic AbstractClasses

=============================================================

aip
*imp

Exception Handling Process:


hM
define Exception?

=>The disturbance which is occured from the application is known as


tes

Exception.
a
nk

define Exception handling process?

=>The process which is used to handle the exception is known as Exception


Ve

handling process.

=>The use the following blocks in Exception Handling process:

1.try

2.catch

3.finally
=>These blocks are executed automatically when exception is raised inthe

application

1.try:

=>try-block will hold the statements which are going to raise the

ii
exception.

ath
=>when exception is raised in try-block,then one object is created for

exception-type-class and the object reference is thrown onto catch

aip
block

syntax:
hM
try

//statements;
tes

}
a
nk

2.catch:

=>catch-block will hold the reference thrown from the try-block.


Ve

=>The required msgs are generated from catch-block.

syntax:

catch(exception-type-class ref-var)

//msg
}

3.finally:

=>finally block is part of exception handling process,but executed

independently without depending on the exception.

ii
=>In realtime finally-block will hold resource closing operations like

ath
IO Close,File Close,DB Close,...

syntax:

aip
finally

{
hM
//statements;

==================================================================
tes

imp
a
nk

define "Throwable"?

=>"Throwable" is a class from java.lang package and which is root of


Ve

Exception-handling-process.

=>This "Throwable" class is extended into the following two SubClasses:

1.Error class

2.Exception class
Hierarchy of "Throwable":

ii
ath
aip
hM
tes

---------------------------------------------------------------------
a
nk
Ve

You might also like