1.Class and method definition
- A java program consists of object of various class type,interacting with one another.
- Object in a program can represent either object in e real world.like automobiles,houses and employee.
- Class is a kind of object.it is a like a plan or a blueprint for constructing specific object
2.Information hiding and encapsulation
- A programer who is using a method that you have defined does not need to know the datail of the code in the body of the method definition to be able to use the method.
- We can use the scanner method without even looking at the definition of the method.it is not that the code contain some secret that is forbidden to you
- Designing a method so that it can be used without any need to understand the fine detail of the code is called information hiding
- The two terms mean the same thing is context.this use of the term abstraction should not be surprising
3.Object and reference
- Variable of a class type name object in a way that is different from how variables of a primitive type store their value.every variable, whether of a primitive type or a class type,is implemented as a memory location.
- The object itself is not stored in the variable,but rather is some other location in memory.the adress of this other memory location is called reference to the object.
- There is a reason why variables of a primitive type and variable of a class type name behave in a diffrent ways.every value,of a given primitive type,such as the type int,always requires the same amount of a memory
- Java has a maximum value of type int,and so value of type int cannot exceed a
certain size in memory however,an object,such as an object of the class string,might be any
size,making it difficult for the system to set aside a fixed amount of space for variables that name
object.
4.Graphics
supplement
- Now that we have explained method and parameter more completely,we will revisit material from the previous graphics supplement to give more detail explanation.we will :
-Explain the graphics class more completely
- -Use methods rewrite one of our previous graphics applet
method similar
Tiada ulasan:
Catat Ulasan