270 likes | 358 Views
Item : 1. RM 4.50 2. 7 ekor lembu 3. π = 22/7 = 3.1415...... 4. 0 = false, 1=true. Nilai mata wang Nilai bilangan Nilai dalam bentuk angka perpuluhan Nilai dalam takrifan komputer. 6.2.1 Data Types. Definisi : “the type of value to be stored in the memory”
E N D
Item:1. RM 4.502. 7ekorlembu3. π = 22/7 = 3.1415......4. 0= false, 1=true Nilaimatawang Nilaibilangan Nilaidalambentukangkaperpuluhan Nilaidalamtakrifankomputer
6.2.1 Data Types • Definisi: • “the type of value to be stored in the memory” • “jenisnilai yang akandisimpandalam memory” • Data types
6.2.1 Data Types • Definisi: • “the typeofvalue to be stored in the memory” • “jenisnilaiyang akandisimpandalammemory” • Data types
Exercise • Data type ____ hanyamempunyai 8 bits memori. • Data type Short mempunyai ___ bytes memori. • Data type___ mengandungihanya 2 kemungkinannilai, iaitu ___ dan ___. • Data type___ dan ___ mengandungi 4 bytesmemori.
Exercise • Data type bytehanyamempunyai 8 bits memori. • Data type Short mempunyai2 bytes memori. • Data typeBooleanmengandungihanya 2 kemungkinannilai, iaitu0dan1. • Data typeintdanfloatmengandungi 4 bytesmemori.
6.2.2 Variable y=mx+c Contoh: y= 2x+9, x=5: y=? Paksi Y y=mx+c C Kesimpulan: x ialahvariablebagi y dan y ialahvariablebagi x Paksi X “Keranasetiapnilai x akan memberikepadanilai y danjugasebaliknya” x dan y jugadikenali sebagai variable
6.2.2 Variable • Dalam java, Variable ialahsatunama yang diladelkanuntukmenyimpannilaipadamemori Rules for naming Variable: An identifier must start with character (A-z), (_) or ($) The rest of the letter in an identifier an be of any character except those used as operators in Java (+,-,or *) Special character such as #,!,@ and ^ can't be used. Blank and tab space can't be used Java is case sensitive (Student!=student) Keywords listed in Java can't be used as identifiers Dari padacontohtadi x adalah variable kepadapersamaantadi (y=2x+9)
Pengistiharan (declaration) <data type><variable>; Contoh: intjum_pel; • Umpukan (initializing) <data type><variable>=<nilai>; Contoh: doublehargaseunit=2.40;
Exercise • Berikanapa yang dimaksudkandengan Variable? • “satunama yang dilabelkanuntukmenyimpannilaipadamemori” • Apakah variable berikutsahsebagai variable dalam Java? Second! bite the cake 1st name Tidaksah Bubble sah
Exercise • Apakah variable berikutsahsebagai variable dalam Java? Berikansebab variable itusahatautidak Second! bite the cake 1st name Tidaksah Bubble sah bite the cake : variable tidakbolehterpisaholeh spacebar Second! : Tandaserutidakbolehdigunakan 1st name : Variable tidakbolehdimulakandengannombor dantidakbolehmengandungi spacebar
6.2.3 Keywords • Defination: “Keyword are reserved words available in Java language” • Definisi:“Keyword ialahperkataan-perkataankhas yang digunakandalamPengaturcaraan Java” • Setiap Keywords mempunyaifungsi yang tersendiridalambahasapengaturcaraan Java. • Olehituiadilaranguntukdigunakansebagai identifier.
Exercise • Berikanmaksud keywords? • Keyword ialahperkataan-perkataankhas yang digunakandalamPengaturcaraan Java • Antaraberikutmanakahdisenaraikandalam keyword • Tuliskansatupengistiharan (declaration) bilangankeretaadalahsifar. intbil_kereta=0; Byte for goto variable good void
Exercise • Berikan 10 keywords yang andatahubesertajenis keywords
Answers • Berikan 10 keywords yang andatahubesertajenis keywords KEYWORDS TYPES class, cast, instance of, void, synchronized User-defined data types and type related if, else, switch, case, default Conditional For, while, do, break, continue, goto and return Flow control Catch, finally, try, throw, throws Exception handling Abstract, Boolean, byte, char, double, extends, final, Data types, modifiers, class and access specifiers
Definition:“the type of value to be stored in the memory” Rules for naming Variable: An identifier must start with character (A-z), (_) or ($) The rest of the letter in an identifier an be of any character except those used as operators in Java (+,-,or *) Special character such as #,!,@ and ^ can't be used. Blank and tab space can't be used Java is case sensitive (Student!=student) Keywords listed in Java can't be used as identifiers Definition: “the name given to the memory location where a value is stored” Data Type Variable 6.2 Variable, Data types, and Operators kesimpulan Keywords intbil_kereta=0; Definition:“A reserved words that available in “Java Language" and each of the keywords are prefined”