My Ads

Rabu, 22 April 2009

autorun


bottom of form
newest info. . . dictionary program 2.04 just merilis, as complete as it
know bearer autorun. inf
category tips tricks , virus | 13,333 views | 51 comments
may be a large part we have detected to what that autorun. inf, but i am sure stills quite a few not yet know or still less correct realize about file autorun. inf this. this matter is proved stills often we are with person asks about virus autorun. inf, how does manner wipe off it and the others.
this be discussed a little deeper will hit autorun. inf, good that know more know and not yet know to begin a little understand about autorun. inf, good existing structure mendalamnya, benefit, danger and lethal manner autorun. inf.
autorun or autoplay be facilities at operating system that functioned to run file automatically when does media like cd-rom, dvd-rom, flash menyk and another at insert/pair at computer. so that when various media putted into, without we run to whatever, there program that automatic will walk self. fitur this is usually maked use in cd driver that enclosed when buy motherboard / vga. but in this time not mempungkiri even maked use as virus spreader media, especially pass flashdisk. even less with use flashdisk that fungoid at the rains. .
while file autorun. inf self be certain instruction containing file, whereof automatic run when media likes flashdisk/cd putted into to computer. this instruction can be in the form of command to run file exe.
structure autorun. inf
autorun. inf only shaped text file usually and can be opened with text editor like notepad. there code lines general are met mendalamnya. actually there are some part (key) that can be written at autorun, that is [autorun, [content, [exclusivecontentpaths, [ignorecontentpaths, and [deviceinstall. here only be discussed several structures [autorun, because really this often we see (as complete as it can at read here )
open
this command automatic will run file exe existing. for example as follows
open=setup. exe (will run file setup. exe that present one merektory with autorun /root merektory)
open=virus\inivirus. exe (will run file inivius. exe exist in virus folder)
action
to display when appear autoplay dialog.
shellexecute
much the same to by order of open, but can also to besides file exe, belong link website and can augmenting with parameter after file name. example:
shellexecute=http: /ebsoft. web. id
action=kunjungi ebsoft. web. id

icon
to give icon at media that worn (containing autorun. inf). can use file. ico, . exe. etc also. bmp. the example:
icon=myprog. exe, 1
icon=myicon. ico
label
to give label (name) in media that used (name drive cd-rom or flashdisk containing autorun. inf.
label=flashdisk great

shell
to display when click right drive concerned. example for example next:
shell\menu baru=buka example file
shell\menu-baru\command=notepad" file-contoh. txt"
shell=menu new
with code on, so whenever we shall click right drive- will appear menu “buka file contoh”. if first line is caused so the menu “menu baru”. and when does menu at will click be run notepad with will open file “file-contoh. txt”. so when code line mutual connected. if line 1 care of 3 same used so line 3 be ignored.
furthermore when does facilities autorun at eliminate / at non activate, so program at open and shellexecute will not walk automatically. but label, icon and menu will click permanent right will come up. so that more safe, so we can me-nonaktif facilities autorun this. how to? next the explanation:
various means me-nonaktif facilities autorun at windows
· depress and hold back button shift when do we turn on/put into flashdisk/cd-rom (not walk at windows vista).
· me-nonaktif pass registry
· make use facilities gpedit. msc
me-nonaktif autorun pass registry
1. open registry editor, start menu > run, type regedit
2. open key next: hkey_current_user\software\microsoft\windows\currentversion\policies\explorer
3. if there key nodrivetypeautorun, so double click and the value contents wrongly one value next:
decimal hexadecimal effect that produced
181 b5 autorun doesn't walk same ekali for all media
149 95 autorun only mobile to cd-rom / dvd-rom
177 b1 autorun only mobile to flash drive (flashdisk and of a kind it)
145 91 autorun mobile for all media
4. if key nodrivetypeautorun there is no so buak by click right, choose new > binary value. then give name nodrivetypeautorun, and the value contents (double click) with value on.
5. step on only berefek at user concerned. so that berefek at all computer users, do same thing to key: hkey_local_machine\software\microsoft\windows\currentversion\policies\explorer\
if still to use win 9x/me so its way a little differ. as complete as it can be read article here . farther about its way can be read also article next: prevent contagious virus passes flashdisk
make use facilities gpedit. msc
this can be done for windows user 2000, server 2003 and windows xp professional, the steps as follows:
1. from start menu > run, type gpedit. msc then click ok.
2. choose computer configuration > administrative template and click system
3. at panel settings, click right turn off autoplay and click properties (at windows 2000, the name menyable autoplay)
4. click enabled then choose all drives at box turn off autoplay for lethal facilities autorun at all drive.
5. click ok, and enclosing window dialog.
6. restart computer.
for windows user vista, its way as follows:
1. from start menu types gpedit. msc at box start search then will press enter (may be at will display command to will put administrator password)
2. at part computer configuration choose administrative templates then choose again windows components click autoplay policies
3. at panel details, double click turn off autoplay
4. click enabled and choose all drives at box turn off autoplay to me-nonaktif autorun at all drive.
5. restart computer.
if manner on not success menon aktf autorun, so possibility necessary download update as according to windows version that used. the detail as follows:
· windows xp sp2 and sp3 (kb950582 )
· server windows 2003 itanium-based systems (kb950582 )
· server windows 2003 x64 edition (kb950582 )
· server windows 2003 (kb950582 )
· windows xp x64 edition (kb950582 )
· windows 2000 (kb950582 )
reference:
http: /en. wikipedia. org/wiki/autorun. inf
http: /support. microsoft. com/kb/953252/en-us
http: /www. dailycupoftech. com/usb-drive-autoruninf-tweaking/
http: /msdn. microsoft. com/en-us/library/bb776823. aspx

history java

java


history short development java
project java begun in the year 1991, when amount of engineer company to kiss that motorred by james gosling has willing to design a little computer language that be used for consumer device like television channel button box. this project is then is given code name green.
necessity to make little language, and tight code pushes them to start return model ever tried by language ucsd pascal, that is design a language portable that produce code intermediate. code intermediate this then can be used in many computers interpreter accustommed.
because ones kisses has background as user unix so that they are more use c++ as their programming language base, so they are peculiarly develop language berorientasi object not berorientasi procedure. such as those which said gosling ”secara overall, only tool, bot such a aim akhir”. and gosling decide to called the language by the name of “oak” (taken from tree name that grow the office window outdoor correct at kiss)s, but then name oak changed to be java, because name oak be computer language name that there [are] previous.
in the year 1994 a large part person uses mosaic, web browser is not dealed that come from centre supercomputing university illinois in the year 1993. (mosaic a part written by marc andreessen with payment 6.85 per hour, as student university that do practice study. later on his day reachess popularity as one of the founder and technology leader at netscape)
browser truthfully built by patrick naughton and jonathan payne and bloom into browser hotjava we have in this time. browser hotjava written in java to show ability java. but has also idea about a strength in this time called with applet, so that they make browser that can code translator byte intermediate level. “teknologi bukti” this showed in sunworld '95 on 23 mays 1995, inspire crazy about towards java still going on.


criteria “kertas putih” java
author java write influence “kertas putih” that explain plan aim and the superiority. their paper is composed via 11 criterias next:

simple (simple)
syntax to java like syntax in c++ but syntax java doesn't need header file, pointer arithmatic (or even pointer syntax), structure union, operator overloading, class virtual base, and the other. if you know c++ well, so you can move to syntax java easily but otherwise, you certain doesn't have a notion that java simple.

berorientasi object (object oriented)
plan berorientasi object is a technique that concentrate plan in data (object) and interfaces. programming facilities berorientasi object in java basically equal to c++. feature programming berorientasi object in java genuinely proportional with c++, principal difference between java with c++ lays in penurunanberganda (multiple inheritance), to this is java has completion manner better.


distributing (menytributed)
java has library routine vast to merangkai in protocol tcp/ip sepetrti http and ftp easily. application java can open and accessing object to all net kind via url same the easy such as those which usually done a programmer when accessing system file locally.

strong (robust)
java be meant to make a program genuinely can trusted in so many matter. java many emphasized in beginning verification for possibility the happening of problem, verification at the (time) of run0time and decrease possibility incidence error (error). principal difference between java and c++ java has a pointer model that decrease possibility penimpaan (overwriting) in memory and data damage (data corrupt).

safe (secure)
java meant to be used in network distributings. before come up with part, emphasis especially attributed in security problem. java make possible virus free program arrangement, system free of defects.

neutral architecture (architecture neutral)
kompiler arouse a file format with nerve architecture object, program at kompile can be run in many prosesor, here given system run time from java. kompiler java do it with arouse code instructions byte can not be done by certain computer architecture. and more baiik java designed to simplify translating in many computers easily and translated in origin computer at the (time) of run-time.

portabel (portable)
doesn't like in c and c++, at java found dependence at the (time) of implementation (implement dependent). size from primitive data type is determined, as arithmetic behaviour to him. librari or book is part from system that define interfaces portabel.

interpreter
interpreter java can meng-eksekusi code byte java directly in computers that has interpreter. and because process linking in java be process stage the increase by tahapdan light heavy, so development process can be quicker and still in watchfulness.

tall performance (high performance)
although code performance byte at interpretation usually more than memadai, but still found situation that needs performance higher. code byte translatable (at the (time) of run-time) de in engine code to cpu certain where application is walking.

multithreaded
multithreading ability a program to do more than one job all at once. keuntunga from multithreading response character interaktif and real-time.

dinamic
in amount of matter, java be programming language dinamicer compared with c or c++. java designed to adapt with environment then bloom. librari can easily method increase and bew example variable without many influence client. information tipr run-time in java direct (straigtforward).



how java better than c++?


principle base maker java because c++ obvious doesn't fulfill promise as programming berorientasi object. so what wrong from c++ so that java must be made? simple the answer, that is kompatibilitas rear (backward compability).
kompabilitas rearward usually known as ability that guarantee success with make programmer learn swiftly. java use most of all identical convention for variable declaration, let pass parameter, operator and current arrangement. so that equally java add parts either from c++ and wipe off ugly parts from c. java far better from c++ because matters not memilikinya, like several examples next:

global variable
programmer write program in language assembly, and all programs that kept dalan punch in card, programming tool liaison global variable, the problem, by using variable blobal a function can give bad side effects with change global conditon. global variable in c++ sign a program doesn't designed good enough to enkapsulasi data by that logical.
in java, global nomenclature space only hierarchy class. not may be creat outdoor global variable all class. at least global conditon determination is made clearer with enkapsulasi in class. example, system. out. println() often used in program java. this manner accessings output global standard to interpreter java.

goto
several abilities that used as mode fast to finish program without make clear structure statement goto. in c++ known as if-then-goto. sebeleum c++ put into exception handling, goto often used to make alliteration insides exception conditon.
java doesn't has statement goto. java prepare word goto just for watch over so that programmer not confused use it. java has part break that given label and statement continue that be where goto be used part. effective exception handling and definition well in java cause the loss of command need goto.

pointer
pointer or address in memory ability c++ effectiveest also riskiest. usually error happens because “kurang one tempat” or broken it data that kept because crashed latest memory location. this error is one of [the] error yangterburuk difficult to inspected and traced.
although object handling java use pointer, language java doesn't has ability manipulate pointer directly. we can not change integer be pointer, indicate to repeat just any address memory. array be object that defined, not shaped address mememori. at java we can not write before end location that provided to array.

memory allocation
ability c++ same the dangerous with pointer mathematical processing memory management. memory management at c and c++ realized with superiority and function weakness library malloc() and free(). function malloc, allocate memory certain quantity (in byte), and take outside address block. function free, send block that allocated to system for general use. in general can causes memory leakage that cause program walks longer more slower.
java doesn't has function malloc and free, because every complex data structure object, so they are allocated with operator new, allocate space for object in 'heap memory. memory that provided to called 'heap because we are unnecessary again think it as increasing address berstruktur linear. so only shaped object instant collection. got from function new not address memory, but only 'handle for object in heap.

brittle data type
c++ inherit all general data types in c. these types represents round number and piece with various value distance and accuracy. value distance and this type accuracy varies to base on implementation kompiler.
javamemecah this problem is with takes appropriate size for all numeric type base and merger it. certain architecture will experience difficulty or work not optimal to meng-implementasi data type that depend on hardware tightly in interpreter java that given, but here's only manner to guarantee result that can be made to repeat in platform hardware different.

type election (type casting) not safe
type casting effective mechanism in c/c++ that makes us to change type a pointer according to just any. may be we often see form likes this:

memset((void)p, 0, sizeof (struct p)

this use, although not good, but enough safe. of course with consider memory block that indicated by p sekurang0kurang along sizeof (struct p). this must be used gingerly for no condition to investigate to what us choose type truly.
object handling java include complete information about class that is instans a object, so that can be done investigation kompatibilitas type during program walk, and produce exception if happen failure.

arguments list not safe
c++ many liked because the ability lets pointerdengan type just any in arguments list panjang-variabel that known as varargs. varargs simple addition in premis that declares that just any address can be mapped in just any type, type investigation task is extradited to programmer.
very menyenag if java has manner safe towards type to mendeklarasi and let pass arguments list panjang-variabel, but until version 1.0 there is no rule like that.

file header apart
one of [the] considering fitting ability file header, where are we dpata mendeklarasi prototype class we and distribute it with implementation binary code class that -compile. this ability make environment compiler c++ only just can be used. c++ has file format that depend on engine for code that -compile, so that information header can be made coresiden. because interface programmer to class -compile done to pass file header-, so code that -compile very base on what is on file header.
for example programmer glad venture on to want to increase access in several data members private in class that -compile. must be done by person replaced access variable originally private be public in file header and meng-compile a sub class from class that -compile. in java this not may be happen, because at java there is no file header. type and visibilitas member class mencompile into file class java. interpreter java run access arrangement moment program walks, so bot at all there is a way of to accessing variable private from outside a class.

structure not safe
c try to prepare enkapsulasi data passes structure declaration that called struct, and polimorfisme with mechanism union. two this brainchilds produces thin limit between settings to depend on engine critical and dangerous with size limitation. java doesn't has concept struct and union, on the contrary java merger this concept with class.

peng-hacker-an preprocessor
to realize has clear model to is written by programmer, compiler c and c++ use tool equal to that used in times macro assembler. this produce preprocessor c the task looks for special command that is preced fence sign (). preprocessor c often used to build program very difficult read.
java regulate so that we can work without preprocessor, only base on finals keyword to mendeklarasi previous constant is produced with define.

qed
come from language latin quod tight demonstrandum, mean “terbukti. . ! ! ! ”.



grammar matters

progaram java space collection, comment, keyword, identifier, literal, operator, and arbiter.

space
java form free language. unnecessary regulate the location order so that can work. provided there at least one space, tab, or new line between every token before menyisipi operator or arbiter other.

comment
there are some form:
single line comment
preced with sign / and put mengakhir line that given comment.
line comment many
preced with sign / and closed with / all between second sign assumed comment and be ignored by compiler.
writing example:
/
komentar…….
komentar……
/
documented comment
use apparatus javadoc, menngguna component compiler java to automatically produce interface documentation public a class. comment maker rule that changeable by javadoc: before declaration class, method, and variable public must be used marked comment /* to declare documentation comment, ended with sign /. javadoc will identified amount of special variable that is foregone with sign @ insides comment part.
writing example:
/*
komentar….
komentar…. .
/


savings keyword (keywords)
savings keyword identifier special that kept by language java to restrain to how program is defined. this keyword is used to identified types, variable, and program current arrangement mechanism. this keyword only can be used for certain function and can not identifier name a variable, class and method. until denga version 1.0 found 59 keyword likes seen in table:

abstract boolean break byte byvalue case
cast catch char class const continue
default do double else extends false
finals finally float for future generic
goto if implements import inner instanceof
int interfaces long native new null
operator outer package private protected public
rest return short static super switch
synchronized this is throw throws transient true
try var void volatile while

identifier
bdiguna for name class, method, and variable. a variable can be in the form of sequence certain font (big or little), number, under line, and dollar sign. may not be preced by number and has case sensitive.
group java follow nomenclature rule identifier for all method public and variable instans with little beginning font and mark word part furthermore with capital letter, for example nextitem, currentvalue, gettimeofday.
for variable provate and local identifier shaped lower case letter all mengombinasikan with under line, for example next_val, temp_val. for finals variable that represent a constant, used capital letter all, for example tok_brace, day_friday.

literal
besaran constant in java produced by using literal that represent it. every literal represent value a type, where does itself type explain to how value character and how does the storage.


separator (arbiter)

function name simbol
() cage is used to collect parameter in definition and denominating method, also used to declare statement stage, collect statement for program channel arrangement and declare type cast.
{} cage kurawal used to collect automatic value is putted into to into array, also used to define program block, for scope class, method, and local.
[] elbow cage is used to declare type array, also used to distinguish value array.
; statement arbiter semicolon.
, comma arbiter sequence identifier in variable declaration, also used to hook statement insides statement for.
. points duguna to separate package name from sub-paket and class, also used to separate variable or method from reference variable.

variable
variable unit base storage in program java. a variable is defined with combination identifier, type, and scope. base on our place mendeklarasikan, variable can has local or temporary, for example insides alliteration for, or can also shaped variable instans that can be accessinged by all method in class. local scope is declared in bracket kurawal.


data type


java be language example strongly typed language. matter this means that every variable must has type that mendeklarasikan. found 8 primitive types, 6 mengantaranya number type (4 types integer, 2 types floating point), 1 character type char, used mengawa-sandi (encode) unicode, and 1 type boolean.

integer

place type that need reach (inclusive)
int 4 byte - 2.147.483.648 until 2.147.483.647 (only more than 2 milliard)s
short 2 byte - 32.768 until 32.767
long 8 byte - 9.223.372.036.854.775.808l until 9.223.372.036.854.775.807l
byte 1 byte - 128 until 127

floating point

tipetempat membutuhkanjangkauan
float 4 byte coarsely 3,40282347e+38f (7 digits denary significant)
double 8 byte coarsely ± 1,79769313486231570e+308 (15 digits denary siignifi)

char
type char use single quotation mark to declares a char. type char also declare character in the effort mengawa-sandi unicode, be code 2-byte. character unicode most often declared in scheme term pengkodean hexadesimal that begun from \u0000 until \uffff. besides free character (escape ' \u ' that declares character unicode at java found also
\b backspace \u0008
\t tab \u0009
\n linefeed \u000a
\r carriage return \u000d
\” double quote \u0022
\ single quote \u0027
\\ a backslash \u005c

boolean
type boolean has value true and false. this type is used untul logical testing by using operator relasional.

conversion delivers numeric value
binary operation whatever in numeric variable with different type acceptable and treated by like under this:
if type operand double, so other also be treated as double in operation scope.
if operand float, so other also be treated as float.
if operand adalaha long, so other also be treated as long.
conversion that admitted:
byte à short à int à long à float à double

where can we give variable value a type beside left to type beside the right.


operator

assignment operator (=)

shorthand assignment operator

operator usage meaning
= x = y x = x + y
-= x -= y x = x - y
= x = y x = x y
/= x /= y x = x / y
%= x %= y x = x % y


arithmetic operator

operator operation
+ addition
- subtraction
multiplication
/ memvision
% modulo


bitwise operator

operator operation
and
| or
xor
>> shift right
<< shift left
>>> shift right contents with zero


unary operator

operatoroperation
" unary musical note
- minus
+ increment
-- decrement



relational operator

operatoroperation
== equal to
! = musical note equal to
> greater than
< less than
>= greater or equal to
<= less or equal to


logical operator

operatoroperation
! short-circuit musical note
& short-circuit and
|| short-circuit or
? : operator nary if-then-else


operator preseden

highest
() [].
+ --" !
/ %
+ -
>> >>> <<
> >= < <=
==! =


|
&
||
? :
= op=
bottommost


control flow


branching

if - else
form if-else causes execution is run to pass conditon nest boolean so that only program certain part that is run. statement general form if-else:

if (boolean expression) statement 1; [else statement 2; ]

clause else has optional, every statement can be in the form of one statement single or can be in the form of one block statement marked with sign {} (cage kurawal). boolean expression can be in the form of just any statement boolean that produce besaran boolean.

break
java doesn't has statement goto. use goto make branching according to just any that make difficult program memengerti and decrease optimasi compiler certain. statement break in java designed to overcome all cases. term break threaten to process breaks program block. process command runtime to run program behind certain block. to can be indicated block be be given name/label. break also can be used without label to out from a loop and statement switch. use break will show that us out from sutu program block.

switch
statement switch memberii a manner ubtuk send program part based on value a variable or single statement. statement general form switch:

switch (expression)
{ case value1:
statement;
break;
case value2:
statement;
break;
case valuen:
statement;
break;
default;
}

expression can produce a simple type, and every value that mentioned in statement case must shaped type that fit. statement switch work by compare value expression with every value in statement case. if some'x fits so sequence program exist in statement case be run, otherwise there that fit, program will run default


return
java use form sub-routine that called method to mengimplementasi interface prosedural to class object. every moment in method can be used statement return that causes execution mencabang return to caller method.


alliteration (looping)
looping mean to repeating certain program block execution until reached condition to stop it. every has 4 parts:
initialization, program mengyiap alliteration beginning part
program body, statement that want us repeat.
iteration, program often used untu increasing or penguranagn pencacah and index.
minasi, statement boolean that inspected each time during alliteration is carried out to see to what alliteration time has come has been stopped.

while
while alliteration statement most mendasar in java. statement use while will causes rekursi statement continually during statement boolean valuable true. general form from statement while:

[initialization; ]
while (mination)
{ body program;
[iteration; ]
}

do-while
statement use do -while will causes body program will be executed at least 1 time although statement boolean will produce value false. investigation minasi carried out by the end of program. statement general form do - while:

[initialization; ]
do
{ body program;
[iteration; ]
}
while [mination;

for
statement for practise manner to declare a alliteration. statement general form for:
for {initialization; mination; iteration) body program;

if beginning conditon doesn't causes mination valuable true so statement body program and iteration will not be run.

comma statement
sometimes there where do we want to put into more than one initialization statement or minasi, java prepare manner other to declare several statements all at once. comma use to separates statement at limit just for used insides parenthesis for statement for.

continue
statement continue will stop iteration concerned but program will run alliteration remainder up to finished.



class and object


several persons initially, usually doesn't pay attention difference between class and object, they are mencampuraduk second term. let us correct reading code next:

/
here we define a class named niceguy.
save as file niceguy. java and compil file
. you will get file will named
niceguy. class
/

public class niceguy {
private string name;

public niceguy(string name) {
system. out. println(“instantion of niceguy named “ + name);
this. name=name;
}
public void sayhello() {
system. out. println(“hello object oriented world…! ! ! “);
}
public sayhellooutloud() {
system. out. println(“hellloooo object oriented world! ! ! ”);
}
public string getname() {
return name;
}
}
picture 1. definisiclass niceguy


/
here, we make a java application
named ourfirstcode.
save source this in file nameds ourfirstcode. java,
at directory equal to your place keeps
niceguy. java. then compil file, you
get file ourfirstcode. class.
then run this application with mengeti java
ourfirstcode in command lino
/
public class ourfirstcode {
public static void main(string[ args) {
niceguy ng= new niceguy (“butthead”);
ng. sayhello();
ng. sayhellooutloud();

/he's so cute…, who's he? ? ?
string niceguyname = ng. getname();
system. out. println(“oh…! ! ! ! he's “ +
niceguyname. touppercase();
}
}

picture 2. application java

on be example pendefinisian a class named niceguy in picture 1. in picture 2 be code from a application java that named ourfirstcode. in application we use class niceguy to membuet object bertipe niceguy.


pendefinisian class
sintaks in define class:

[modifier class namaclass [extends parentclass
[implements interfaces {
[declaration field
[definition method
}

as described insides has optional elbow cage. thereby, minimal definition from a class possible like next:

class useless {

/…. mmm….

}

bothing that can we intended from object on. example better picture 1. there we are mendeklarasi 1 field and 3 method. in line 8 we are mendeklarasi field that named name bertipe string. in general sintaks to mendeklarasi field:

type namafield;

type from field can primitive (like int, boolean, float, and as it), and can also object (like string, vector, hashtable, and as it).
method that has class niceguy method sayhello() along line 14-16 (method void), method sayhellooutloud() in line 17-19 (method void), and method getname() in line 20-22 (method non-void). in general sintaks in pendefinisian a method:

[modifier return-type namamethod
([parameter1, [parameter2, …, [parameter n) {
[statement;
}

type return can void, primitive data type, or data type object. method with type return non-void must pin up statement return by the end of declaration method that (like in line 21 class niceguy) we also can use word return in method void to out from method.
important part other from definition class constructor. pendefinisian constructor exemplified in line 10-12 class niceguy. constructor used at the (time) of object creation from a class. pendeklarasian constructor resemble with pendeklarasian method, with one exception that is constructor doesn't pin up type return.

[modifier namaconstructor ([parameter 1, [parameter 2, …
, [parameter n) {
[statement;
}


something else necessary registerred about constructor, name constructor must equal to class. constructor without parameter is called default constructor. if we are bot at all mendeklarasi constructor, compiler automatically will make a default constructor.
in picture 2, application ourfirstcode make use class niceguy to creat a object bertipe niceguy mememori (look at line 13 pictures 2). afterwards, reference ng can be used to call method (send message to it) or accessing field from object concerned.
reference like home address while object the house. given the address, we can achieve house that meant.


inheritance
one of [the] important topic in oop inheritance (character inheritance). with inheritance, software development can work efficienter and quicker. blessing inheritance can use definition class ever be made previous to make class other that resemble class. look at example next:

public class kattworld {
public static void play (string args[) {
katt k = new katt();
k. speak();
anggora a = new anggora();
a. speak(); a. jump();
siam s = new siam();
s. speak();
}
}

class katt {
public katt() {
system. out. println(“katt constructor”);
}
public void speak() {
system. out. println(“miaww…”);
}
}

class anggora extends katt {
public void jump() {
system. out. println(“crash…boom…”);
}
}

class siam extends katt {
public siam() {
system. out. println(“siam constructor”);
}
public void speak() {
system. out. println(“mmurrrr…mmurrrr…”);
}
}
picture 3. cat story


first matter that must be payed from picture 3 care of manner do inheritance. coontoh on has one class named katt (line 12-19). then membut class another that has character likes katt, but has uniqueness self. the example class anggora, we can make subclass from katt (line 21-25).
now can be said that katt be parentclass (baseclass or superclass) from class anggora. in general we can define a class as descendant from baseclass by:

class namaclass extends baseclass {
[statement;
}

method overiding
we make variant new other from katt with manner mews murr…. murr…murr…. we bame variant that siam. we define siam as subclass from katt, but now we do method overiding, we define to repeat method speak() insides definition class siam. if run will produce output:

katt constructor
miaww…
katt constructor
miaww…
crash…boom…
katt constructor
siam constructor
mmurrr…mmurrr…

line 6 and 7 showed sewaktu go on construction/instantiasi object bertipe siam. default constructor katt run beforehand. this show that default, except we ask other, from baseclass automatically run beforehand before constructor from class concerned.

this
this actually a variable read-only (irreversible the value). with variable this, we get reference/pointer aims object kini. is conceiving your application is walking, at the (time) of certain that run by your computer is method amethod() property object anobject. from method amethod() you want reference to object kini that is object anobject itself. to that's we use variable this in method amethod() property object anobject. look at example next:

public class beavisandbuttheadstory {
public static void play (string[ args) {
memvinebeing beavis = new memvinebeing (“beavis”);
memvinebeing butthead = new memvinebeing (“butthead”);
/guess what's gonna happen next…
beavis. messwith (butthead);
butthead. makerevenge();
}
}

class memvinebeing {
private string name;
private memvinebeing badddivinebeing;
public memvinebeing (string name) {
this. name = name;
}
public void messwith (memvinebeing anotherdivinebeing) {
anotherdivinebeing. kapow(this);
}
public void kapow (memvinebeing badddivinebeing) {
system. out. println(badddivinebeing. getname()+”! ! ! ! damn you! ! ”);
/forgive but musical note forget…
this. badddivinebeing = badddivinebeing;

}
public void makerevenge() {
of (badddivinebeing! = null) {
badddivinebeing. kapow(this);
}
}
public string getname() {
return name;
}
}

picture 4. keyword use example this

beavis begin flutter with strike butthead, beavis give butthead reference on th. this matter is done with give argument this in denominating method kapow(divinebeing badddivinebeing). with reference he gets that, in a moment butthead dapak return to send message makerevenge() to beavis. butthead remember right who strike it, because sewaktu he is striken, he keeps reference to object beavis that in variable badddivinebeing the property, mendeklarasikan in line 13. practice on called callback.
use other from this visible in line 15 and 23. in line 15, we aim to decide variable name at declaration in line 12, but now is emerging conflict in variable nomenclature. insides arguments list in constructor we also define variable other also named name (line 14). variable reach name in line 12 include all spaces in class memvinebeing, while variable name in line 14 has limited reach insides constructor that. to say me wish for name global not name local, we break through out with keyword this. visible in picture 5.



class memvinebeing {
private string name;

private memvinebeing badddivinebeing;
public memvinebeing (string name) {

this. name = name;

}


picture 5. out of the box experience

abstract
abstract method method not yet has implementation. we can declare a method abstract with membubuh keyword abstract in declaration method. in general sintaks from pendeklarasian method abstract:

abstract return-type namamethod ([daftar-parameter);

example:

public class explainabstract {
public static void play (string args[) {
singer joshua = new pnyanyi();
joshua. berkesenian();
pemrogram raka = new pemrogram();
raka. berkesenian();
}
}

abstract class artist {
public abstract void berkesenian();
public void tidur() {
system. out. println (“zzzz…”);
}
}

class pemrogram extends artist {
public void berkesenian() {
system. out. println(“tap…tap…click-
click…tap…plak! click…dor! ! ! ”);
}
public void tidur() {
system. out. println(“buzzz…ngingggg…. ”);
}
}

class singer extends artist {
public void berkesenian() {
system. out. println(“tralala-trilili…”);
}
}

picture 6. example pendeklarasian method abstract


static method
in our previous examples must menginstantiasi/make object beforehand before can use method or accessing field in class concerned. but with define a field or method as static, we can accessing field method without having to do instantiasi beforehand. look at example next:

public class mygeomutil {
int iamnotpopular = 13; static int iamcelebrity = 7;

public static double luassegiempat (float length, float width) {
return length width;
}
public static double luassegitiga (float covering, float tall) {
return 0.5 covering tall;
}
public static double luassegitiga (float a, float b, float gamma) {
/function sin (double angel) get corner input
/in radian angle musical note angel, you prevert. . !
return 0.5 a b math. sin(gamma / math. pi;
}
}

picture 7. definition mygeomutil



finals
with add modifier finals in declaration a method, we shall decide that method in class tiidak can be befalled in subclass later may be be made. one of [the] reason to membubuh finals in method at a base class because method that so fundamental for work instance class, so that if at implementation according to differ by subclass (that can be written by programer wrong) causes work instance that bot true. finals general form method:

[modifier finals namamethod() {
/…mmmm…. .
}

also can memberlakukan for class finals, we can not make descendant from class finals. finals general form class:

finals class namaclass extends parentclass {
/…mmm…
}

interfaces
in also we can mendeklarasi method interfaces, field (with a few note of course), and also can make chain inheritance such as those which be done in class. see program example under this:

import java. awt. ;
import java. awt. event. ;

public class austinpower extends frame implements mouselistener {
button behave;

public static void play (string args[) {
austinpower asywhoshaggedme = new austinpower();
spywhoshaggedme. setsize(100,100);
spywhoshaggedme. setvisible(true);
}

public austinpower() {
behave = new button (“i general a button”);
behave. addmouselistener(this);
add(behave);
}

public void mouseentered(mouseevent me) {
behave. setlabel (“click me…! ! ! ”);
}

public void mouseexited(mouseevent me) {
behave. setlabel (“come to me…! ! ! ”);
}
public void mousepressed(mouseevent me){
public void mousereleased(mouseevent me){
public void mouseclicked(mouseevent me){
}


picture 8. interfaces use

while interfaces mouselistener like as described under this:

package java. awt. event;

import java. filch. eventlistener;
/*
the listener interfaces for receiving mouse event on a
component.
@version 1.7 07/01/98
@author carl quinn
/
public interfaces mouselistener extends eventlistener {
public void mouseclicked (mouseevent e);
public void mousepressed (mouseevent e);
public void mousereleased (mouseevent e);
public void mouseentered (mouseevent e);
public void mouseexited (mouseevent e);
}

picture 9. interfaces declaration mouselistener

in example on, we say that austinpower mengimplementasi mouselistener. in general interfaces declarable as follows:

interfaces namainterface [extends parentinterface {
[declaration field (constant
[declaration method

mendeklarasi method in interfaces resembles with mendeklarasi method abstract, where is declaration method not ended cage pair kurawal, but semicolon sign:

return-type namamethod (parameter [list);

there one note, field that defined in interfaces automatically has static and finals, mean them only act as constant.
while in general, a class made so that mengimplementasi a interfaces by as follows:

class namaclass [extends parentclass [implements interface1, interface2, …
{ [declaration field
[declaration method property class this]

implementation [declaration method that defined in
interfacess at implementation by class ]
}

in example on with mengimplementasi mouselistener, class austinpower said menandatangai a contract that declare that he can to show behaviours a mouselistener (that is react towards event that mouse).
all method definition in interfaces really abstract, there is no the implementation. one of [the] consequence from abstraction totality in that interfaces all method as described in interfaces must at implementation by implementor.


polymorphism
polymorphism defined as ability several objects bertipe same react according to differ towards message same. see example under this:

public class kattparty {
public static void play (string args[) {
katt[ kandangkatt = new katt[3;
kandangkatt[0 = new anggora();
kandangkatt[1 = new siam();
kandangkatt[2 = new katt();
for (int i am = 0; i am < 3; i++) {
kandangkatt[i. speak();
}
}
}

picture 10. cat party

menyetiap iteration in loop on, basically we are mengirima message same to objects bertipe same (that is katt, as according to definition array in line 3), speak(). although so, obvious each react with its way self.
example other from polymorphism that is, for example we make client/server application, where client send objects katt (and of course also whatever descendant katt) to server. in case, server settles for kat that without too make a problem out of the spesification difference. untu that is code menyerver possible like next:

katt k = null;
while (true) {
k = receive();
}


of course for this case, is not correct if, according to static we are mengasosiasi k with class siam (example with pendeklarasian siam k = null). in code on, pengasosiasian k with clas specific (anggora, siam or another) done at the (time) of run-time, that is when return value from denominating receive() -assign to k. that's that called dynamic/late binding.

operator instanceof
how suppose server side want to detect type specific from object katt that accepted it? see example kattparty that modified next:

public class kattparty {
public static void play (string args[) {
katt[ kandangkatt = new katt[3;
kandangkatt[0 = new anggora();
kandangkatt[1 = new siam();
kandangkatt[2 = new katt();
for (int i am = 0; i am < 3; i++) {
kandangkatt[i. speak();
if (kandangkatt[i instanceof siam) {
system. out. println(“wow, it's a siam…”);
} else if (kandangkatt[i instanceof anggora) {
system. out. println(“look, they are sent us anggora…”);
}else {
system. out. println(“well…it could be lucifer, ” +
“ or alleys or regular katt”);
system. out. println(“but one thing for sure…it's katt” +
“ praise the lord”);
}
}
}
}
picture 11. to know more about katt

operator whom we wear instanceof. a instanceof b, mengevaluai what object a bertipe b (b name class). that evaluation produces value true if name class from object a b or name parent/grandparent/greatgrandparent /further from class from object a b.
also true valuable evaluation if b interfaces name and a mengimplementasi b. so also if parent/grandparent/greatgrandparent/further from class object a mengimplementasi b.
short word. if a instanceof b produce true, mean object a can show behavior menyyaratkan by class or interfaces b.

package
we are the refraction groups class (as well as interfacess) related (because the kind/the function/reason other) in a package. may be it is better if class geometric we make to gatherred in a package named com. raka. geoms

/simpan as graphic. java /
package com. raka. geoms;
public abstract class shape {
…….
}
picture 12. package---1

/ save as rectangle java /
package com. raka. geoms;
public class rectangle extends shape {
……………
}
picture 13. package---2

/ save as triangle. java /
package com. raka. geoms;
public class triangle extends shape {
……………
}
picture 14. package---3

several profits mengorganisasi class our product is in a package:
escaped from nomenclature conflict. may be there another person, membelahan world other, make class that named rectangle also. distinguish between rectangle we are with other fully qualified name. fully qualified name from class rectangle we are com. raka. geoms. rectangle.
regular. will get a class certain easy given the name package-.

in example on, each member from package com. raka. geoms kept at file apart, and mendeklarasikan as public. thereby class/program other (bonmember com. raka. geoms) can mengimport clas-class we on. we also can define several class all at once in a file java, like example next:

/ save as nuclearwarhead. java /
package com. raka. lethal;

public class nuclearwarhead {
……………
}
class sarin {
………………….
}
class uzi {
………………….
}
picture 15. all in life

if we are compilation nuclearwarhead. java on, we shall get three files class, that is nuclearwarhead. class, sarin. class, uzi. class. all the it will be member from package com. raka. lethal. but only nuclearwarhead that can be used directly from outside package com. raka. lethal, because only nuclearwarhead mendeklarasikan as public, rest dedeklarasi as protected (the default), so that only can be used by class that united insides com. raka. lethal.
now to is using class found on com. raka. geoms from outside com. raka. geoms, we know keyword import. like example under this:

package com. drawworks. threedee;
import com. raka. geoms. ;
……

public class cube {
……
rectangle r = new rectangle ();
…. .
}
…. .
picture 16. import class.

if pemrogram com. drawworks. threedee aim to use class found on java. awt also where found also class rectangle, so moment here's menggunaka fully qualified name. like example under this:

package com. drawworks. threedee;
import com. raka. geoms. ;
import java. awt. ;
……

public class threeworld extends canvas {
……
com. raka. geoms. rectangle r = new com. raka. geoms. rectangle ();
…. .
}
…. .
picture 17. fully qualified name

package insides harddisk can we are organization in a directory structure. files class member com. raka. geoms gatherred in directory structure. you may conclude that every syllable in name package name a directory.












exception handling

exception conditon below par that appear at one particular program part at the (time) of run. exception handling in java bring program error management moment run to into orientasi-objek. exception java object that explain a exception conditon that appear at one particular program part.
moment a exception conditon appears, a object exception made and putted into into method that causes exception. method eligible to handle exception based on certain type. method this also watch over so that not out too early pass a exception, and has a program block that run just prior to a exception causess the method returns to caller.
exception can appear irregular in a method, or can also be made according to manual and later report amount of error conditon to method that call.


base exception handling
exception handling in java regulated with five keyword: try, catch, throw, throws and finally. basically try used to execute a program part, and if appear error, system will do throw a exception that can you catch based on the exception type, or you give finally with penangan default.
follow form base exception handling part:

try {
/ block of code
}
catch (exceptiontype1 e) {
/ exception handler for exceptiontype1
} catch (exceptiontype2 e) {
/ exception handler for exceptiontype2
throw (e); / re-throw the exception…
}
finally {
}

exception type
mempuncak hierarchy class exception found one class that called throwable. class this used to represent all conditons ekasepsi. every exceptiontype in general form on subclass from throwable.
two subclass direct throwable defined to divide class throwable be two different branches. one, class exception, be used for exception conditon that must be caught by program whom we make. while other can catch class we subclass to produce exception conditon.
second branch throwable class error, define conditon not supposed to caught in normal environment.


exception can not be caught
exception object automatically produced by runtime java to receive a exception conditon. look at example next:

class exc0 {
public static void play (stinr args[) {
int d = 0;
int a = 42 / d;
}
}

moment runtime java try meng-eksekusi distribution, be seen that the divider zero, and will form new exception object that causess program delayed and must deal with error conditon. we are not yet mengkode a penangan exception, so that default exception handling soon will be run. product from program on:

java. lang. arithmeticexpression: /by zero
at exc0. play (exc0. java: 4)

next another example from exception:

class exc1 {
static void subroutine() {
int d = 0;
int a = 42 / d;
}

public static void play (stinr args[) {
exc1. subroutine();
}
}

output-:

java. lang. arithmeticexception: / by zero
at exc1. subroutine(exc1. java: 4)
at exc1. main(exc1. java: 7)


try and catch
keyword try be used to determine a program block that must be watched over towards all exceptions, after block try insert part catch, will determine exception type that be caught. look at example next:

class exc2 {
public static void play (string args[) {
try {
int d = 0;
int a = 42 / d;
}
catch (arithmeticexception e) {
system. out. println(“division by zero);
}
}
}

throw
statement throw used to explicitly throw a exception. first we must get handling in a instance throwable, pass a parameter intoes part catch, or with make it to use operator new. statement general form throw:

throw throwableinstance;

execution current soon delayed after statement throw, and statement furthermore will not be achieved. block try closest be inspected to will see if has part catch that fitt in with type instance throwable. otherwise found that fit, so arrangement mempindahkan to statement. otherwise, so statement block try furthermore inspected, so further until extern exception handling stops program and print penelusuran all stacks until statement throw. example:

class throwdemo {
static void demoproc() {
try {
throw new nullpointerexception(“demo”);
}
catch (nullpointerexception e) {
system. out. println(“caught inside demoproc…”);
throw e;
}
}

public static void play (string args[) {
try {
demoproc();
}
catch (nullpointerexception e) {
system. out. println(“recaugt: “ + e);
}
}
}

output:
caught inside demoproc
recaught: java. lang. nullpointerexception: demo


throws
keyword throws used to identified exception list may be -throw by a method. if the exception type error, or runtimeexception, or a subclass, this rule bot applicable, because not supposed as normal part from program work.
if a method explicitly men-throws a intans from exception or subclass, outdoor runtimeexception, we must mendeklarasi the type with statement throws. this define to repeat declaration method previous with sintaks as follows:
type method-name (arg-list) throws exception-list { }

example:

class throwsdemo {
static void procedure () thorws illegalaccessexception {
system. out. println(“inside procedure”);
throw new illegalaccessexception(“demo”);
}

public static void main(string args[) {
try {
procedure();
}
catch (illegalaccessexception e) {
system. out. println(“caught “+ e);
}
}
}

output:
inside procedure
caught java. lang. illegalaccessexception: demo


finally
moment a exception is throwed, program channel in a method make stripe inclined not linear pass method, jump over certain lines, even may be out ahead of schedule in where there is no part catch that fit. sometimes necessary be ascertained that program part that given will walk, bot give a dam exception what is going on and caught. keyword finally can be used to determine program part like that.
every try want at least one part catch or finally that fit. if we don't get part catch that fit, so part finally be executed before end program, or each time a method will return to the caller, pass exception can not be caught, or pass statement return, part finally be executed before return to method return.
next program example that show several method secretory variously, not one even also without execute part finally-.

class finallydemo {
static void proa() {
try {
system. out. println(“inside proca. . ”);
throw new runtimeexception(“demo”);
}
finally {
system. out. println(“proca is finally”);
}
}

static void prob() {
try {
system. out. println(“inside procb. . ”);
return;
}
finally {
system. out. println(“procb is finally”);
}
}

public static void main(string args[) {
try {
proca{;
}
catch (exception e);
procb();
}
}

output:
inside proca. .
proca is finally
inside procb. .
procb is finally


multithreading

many problems in programming wants ability a program to do several things all at once, or is giving handling soon towards a insident/ event certain with is postponing activity that being run to is handling event and final return to continue activity that delay.
example, in network application system, we can make a program do local computation with data that got from network, at the (time) of program wait data addition incoming from network. without multithreading, program must do it according to sekuensial in a single program channel (that is channel control principal), preced with data overall arrival waiting, new then computation. in wait, computer presents in the situation idle that causes ketidakefisienan in overall program.
with multithreading we can creat two thread dinamicly, that is thread that vigil mempintu gate, wait to enter it data. , and thread that do local computation on data that available.


multithreading and java
thread (oftentimes called also lightweight process or execution context) a singlesequentialflow of control insides a program. simply, thread a subprogram that walk insides a program.
as does a program, a thread has beginning and end. a program can has several thread mendalamnya. so program the difference multithreaded has several flow of control that walk according to konkuren or parallel while program singlethreaded has only one flow of control.








a program







gb. 1. two thread in one programs


two programs that run separately (from command lino separately), present in two address space apart. on the contrary, second thread in picture on present in address space same (address space from where is second thread run)ed program.
if that program walks on engine with single processor, so thread that run according to konkuren(dengan execute according to by turns from one thread to thread another). if that program walks on engine with multiple processor, so thread that can be run parallelly (each thread walk at processor apart).


concurrency parallelism

time time















gb. 2. konkurensi and parallelism


picture 2 can explain difference between konkurensi and parallelism. language java has ability multithreading built-in, in java virtual macjine found thread scheduler that determine thread which in action in a time g certain. scheduler in jvm support preemptive multithreading, that is a thread with tall priority can menyeruak enter and is intercepting thread that in action, this ability is very beneficials in make application real-time.
scheduler in jvm also support non-preemptive multithreading i(atau often called also cooperative multithreading), that is thread that in action can not be intercepted, he will dominate time cpu, until he finishes the task or explicitly allow self to stop and give a chance for thread other.


alive cycle a thread























gb. 3. state from thread
newborn
sevbuah thread present in state this when he is at instantiasi. a room mememori allocated to thread that, and finish the initialization stage.

………
thread timerthread = new timerthread();
……. .

in state this, timethread not yet enter in scheduling scheme thread scheduler.


runnable
in state this, a thread stay in scheduling scheme, but he is not in action. we can make timerthread we make previous step into state runnable with:
…. .
timerthread. start();
……

when precisely timerthread in action, determined by thread scheduler.


running
in state this, thread in action. time quotum in action for thread this determined by thread scheduler. in certain case, thread scheduler justifiably meng-interupsikegiatan from thread seddang in action (for example there thread another with priority tall).
thread in a state of running can also shift down voluntaryly, and enter to return to state runnable, so that thread other that is waiting giliran(runnable) to get to chance to in action. tindda thread that shift down voluntaryly that usually called yield-ing.
public void run() {
…….
thread. yield();
…….
}
blocked

in stage inii thread not in action and ignored in scheduling thread scheduler. thread that bloc is waiting until certain terms is being fulfilled, before he returns to enter to into scheduling scheme thread scheduler (enter state runnable again). a thread be bloc because matters next:
a. thread that sleep for certain, like next:
public void run() {
……
try {
thread. slepp(3000);
/thread yg in action will sleep during 3000 milisecond=3menit
}
catch (interruptedexception e) {
…….
}

b. thread that is - suspend(). thread -suspend() that can enter to return to state runnable when does he resume(). like matter next:
……
/timerthread soon will enter state blocked
timerthread. suspend();
………
timerthread. resume();
/timerthread return to enter state runnable
……
when thread calling method wait() from a object that he key. thread can return to enter state runnable if (there are) any thread other that call method notify() or notifyall() from object.

when thread this wait expiry activities that i/o. for example, if a thread wait incoming bytes from computer network so automatically thread step into state blocked.

when a thread trying to accessing critical section from a object that being locked by thread other. critical section code method/block marked with word synchronized.


dead
a thread automatically called to die when method run() - he menuntaskan (return from method run(). example under this thread that will taste state running for once moment thread scheduler give a chance to running, he will print “ i'm doing something…. something stupid…. but i'm proud of it”… then die.

public class mythread extends thread {
…. .
public void run() {
system. out. print(“i'm doing something…”);
system. out. print(“something stupid…”);
system. out. println(“but i'm proud of it…”);
/ mythread will die so line on finished be executed
}
……
}