-
Notifications
You must be signed in to change notification settings - Fork 1
/
notes
70 lines (54 loc) · 3.57 KB
/
notes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
encapsulation and polymorphism :
the process of wrapping up of data and methods into a single unit is called as encapsulation.in java it is also known as information hidding since it involves hidding of many important details of an object from the user it can be accessed by the methos of an object and this insulation of data from direct access by the programme is called as data-hidding.
polymorphism(poly means many and morps means forms) => it is the facility that helps object to react differentky to the same operation java supports run time polymorphism with the help of overridding method. we can say polymorphism is a process in which a class to and overridden method os resolved at runtime rather then at the compile time this process is also calld as late binding or dynamic binding.
constructor , finilizers and destructors :
like c++ java provides a spacial member functo for initializing the data members of a class called constructor .
it is executed automatically at the time of object creation.
As method constructor can be of 2 type : with and without argument.
1. constructor has the same name as the class name and constructor has no return type.
2. constructor can also be overloaded
3. when we pass the object of the class as an argument to the constructor such is constructor is known as the copy constructor
lab - 7 (interface)
1> apply concept of interface in various programme and utilize it as multiple inheritance
2> crating package and importing in our programme.
interface => java does not support multiple inheritance to enjoy the benefits of multiple inheritancejava provides interface.
an interface forces the classes tp impliment certain methods with certain signature , once an interface in defined you can
impliment any number of classes from this interface.
the syntex is :
interface interface_name{
members;
}
the difference between interface and classes methods in an interface in declared only not imlimented and you have to impliment
that interface in a class.
the syntex is :
class class_name impliments interface_name,interface_name1,interface_name2{
}
packages in java :
package is a collection of classes and interfaces of similar nature.
1> they are used to avoid class name collision
2> they enable class reusability
3> software distribution is also easier now
4> they protect classes from the access by the external classes
their are 2 type if package
1> built in package
2> user defined package
1>built in package
classes with related functionality's are bundled togethere in same package,where they share code data or methods.
eg :
java.lang
java.util
2> user defined package :
it is possible in java to create our own package in order to organize related classes
such packages are known as user defined packages.
syntex is :
package name_of_package;
que.1 create a package with name my pack in this package create 2 class first and second and in this class 2 methods
show1() and show2() and import the package in ain class and use the method reside in this class.
Exception handling :
Exception is an abnormal condition that arises in a code sequence at run time and disrupts the normal
flow of programme.
object --- throwable 1>error 1a>AWT error 2a>virtual m/c error
2>Exception 2a>ioexception 2b>run time Exception
2aa>I/O Exception 2ab>filenot found Exception
2ba>arithmatic Exception 2bb>null pointer Exception
2bc>array index outof bound Exception