Java Names and Labels
ASCIIAmerican Standard Code for Information Interchange
ASCII is now the universal standard for computers to decode all letters of the alphabet and special characters.
Powerpoint TemplatesPage #ASCII
Symbol64656667686970717273747576777879@ABCDEFGHIJKLMNOPowerpoint TemplatesPage #Castingprocess of converting a value to the type of a variable
Powerpoint TemplatesPage #Concatenation
process of joining values togetherPowerpoint TemplatesPage #Constant
identifier whose value can never be changed once initializedPowerpoint TemplatesPage #Identifier
user-defined name for methods, classes, objects, variables, and labelsPowerpoint TemplatesPage #Java Keyword
word used by the Java compiler for a specific purposePowerpoint TemplatesPage #Literals
values assigned to variables or constantsPowerpoint TemplatesPage #Unicode
Universal code that has a unique number to represent each characterPowerpoint TemplatesPage #Variable
identifier whose value can be changedPowerpoint TemplatesPage #Identifiers are user-defined names for methods, variable, constants, and classes. Rules:The first character of your identifier should start with a letter of the alphabet, an underscore ( _ ), or a dollar sign ($). After that, the identifier can then be composed of alphanumeric characters and underscores.Powerpoint TemplatesPage #2. Create identifiers that are descriptive of their purpose. If your identifier is composed of several words, capitalizing the first letter of each word is a good programming practice.Powerpoint TemplatesPage #Valid IdentifiersInvalid IdentifiersMyIdentifierNameMy Identifier Namemyidentifiernamemy+identifier+namemy_identifier_namemy-identifier-name_myidentifiernamemy_identifiers_name$myidentifiernamemy_identifier_&_name_3names3namesPowerpoint TemplatesPage #Data types Primitive data typesReference data types Powerpoint TemplatesPage #Primitive data typesData typeExample/s stringhello worldbooleantrue, falsechar A, z, \n, 6byte1short11int 167long 11167Lfloat 63.5Fdouble 63.5Powerpoint TemplatesPage #Data TypeLengthRangebyte 8 bits-2 7 to 2 7 -1short 16 bits-2 15 to 2 15 -1int 32 bits-2 31 to 2 31 -1long 64 bits-2 63 to 2 63 -1Powerpoint TemplatesPage #Variables are identifiers whose values can be changed. general syntax is :
;
int numberPowerpoint TemplatesPage #Examples booleanPassed;charEquivalentGrade;byteYearLevel;shortClasses;int Faculty_No;long Student_No;float Average;DoubleLogarithm;StringLastName; Powerpoint TemplatesPage #Examples booleanPassed =true;charEquivalentGrade =F;byteYearLevel =2;shortClasses =19;int Faculty_No =6781;long Student_No =76667L;float Average =76.87F;doubleLogarithm=0.879463434;StringLastName =Bonifacio; Powerpoint TemplatesPage #Examples booleanPassed =true, Switch;charEquivalentGrade =F, ch1,ch2;byteYearLevel =2;shortClasses =19;int Faculty_No =6781, Num1;long Student_No =76667L, Employee_No, Long;float Average =76.87F, Salary;doubleLogarithm =0.879463434, Tax, SSS;StringLastName =Bonifacio, FirstName=Andres; Powerpoint TemplatesPage #Casting Powerpoint TemplatesPage #public class Core{public static void main (String [] args){ int x=10, Average=0; double Quiz_1=10, Quiz_2=9; char c=a;Average=(int) (Quiz_1=Quiz_2)/2);//explicit casting x=c; //implicit casting from char to intSystem.out.println(The ASCII equivalent);System.out.println(of the character a is : +x);System.out.println(This is the average of the two quizzes: +Average);}}
Powerpoint TemplatesPage #22
Powerpoint TemplatesPage #
public class Core{
Powerpoint TemplatesPage #24
public static void main (String [] args){
Powerpoint TemplatesPage #25
int x=10, Average=0;double Quiz_1=10, Quiz_2=9;char c=a;Powerpoint TemplatesPage #26
Average=(int) (Quiz_1+Quiz_2)/2);//explicit casting
Powerpoint TemplatesPage #27x=c; //implicit casting from char to int
Powerpoint TemplatesPage #28
System.out.println(The ASCII equivalent);System.out.println(of the character a is : +x);System.out.println(This is the average of the two quizzes: +Average);}}
Powerpoint TemplatesPage #29public class Core{public static void main (String [] args){ int x=10, Average=0; double Quiz_1=10, Quiz_2=9; char c=a; Average=(int) (Quiz_1+Quiz_2)/2); //explicit casting x=c; //implicit casting from char to int System.out.println(The ASCII equivalent); System.out.println(of the character a is : +x); System.out.println(This is the average of the two quizzes: +Average);}}
Powerpoint TemplatesPage #30
Powerpoint TemplatesPage #Get sheet of paperPowerpoint TemplatesPage #Write V if the identifier is valid.Write I if it is invalid.Powerpoint TemplatesPage #variable 2 mainAverage+quizzes principal_amount$ratesum_quiz1&quiz2 int 3xPowerpoint TemplatesPage # x-5 PRODUCT firstname AreaofSquare periMeter num_1 a*bPowerpoint TemplatesPage #IIIVVIII
9. I10. V11. V12. V13. V14. V15. IPowerpoint TemplatesPage #Powerpoint TemplatesPage #Powerpoint TemplatesPage #Identify the data type for variables and literals given.Powerpoint TemplatesPage # x = a quiz1 = 90.75 age = 15 age2=15 years old num3 = 10.91FIdentify the data type for variables and literals given.Powerpoint TemplatesPage #6. failed = false7. interest = 10008. size = small9. cents = 0.8753910. date = 11-30-1998 Identify the data type for variables and literals given.Powerpoint TemplatesPage # x = a quiz1 = 90.75 age = 15 age2=15 years old num3 = 10.91FIdentify the data type for variables and literals given.Powerpoint TemplatesPage #6. failed = false7. interest = 10008. size = small9. cents = 0.8753910. date = 11-30-1998 Identify the data type for variables and literals given.Powerpoint TemplatesPage #Create a program that will compute the sum of 20 and 11.5 and display the result.Powerpoint TemplatesPage #let
num1 = 20num2 = 11.5sum = num1+num2Variables (Identifiers)Powerpoint TemplatesPage #
int num1 = 20double num2 = 11.5double sumPowerpoint TemplatesPage #public class Sum
Powerpoint TemplatesPage #public class Sum{
Powerpoint TemplatesPage #public class Sum{public static void main (String[]args)
Powerpoint TemplatesPage #public class Sum{public static void main (String[]args) {
Powerpoint TemplatesPage #public class Sum{public static void main (String[]args) {int num1=20;double num2=11.5;double sum;
Powerpoint TemplatesPage #public class Sum{public static void main (String[]args) {int num1=20;double num2=11.5;double sum;
sum=num1+num2;
Powerpoint TemplatesPage #public class Sum{public static void main (String[]args) {int num1=20;double num2=11.5;double sum;
sum=num1+num2;System.out.println(The sum is: +sum);
Powerpoint TemplatesPage #public class Sum{public static void main (String[]args) {int num1=20;double num2=11.5;double sum;sum=num1+num2;System.out.println(The sum is: +sum); }
Powerpoint TemplatesPage #public class Sum{public static void main (String[]args) {int num1=20;double num2=11.5;double sum;sum=num1+num2;System.out.println(The sum is: +sum); }}
Powerpoint TemplatesPage #public class Sum{public static void main (String[]args) {int num1=20;double num2=11.5;double sum;
sum=num1+num2;System.out.println(The sum is: +sum); }}
DeclarationsFormula Powerpoint TemplatesPage #
The sum is: 31.5Powerpoint TemplatesPage #
1. Create a program that will get the difference of 150 and 75. Then display the result.
Use Difference as the class namePowerpoint TemplatesPage #
2. Create a program that will get the average of 35, 42 and 23. Then display the result.
Use Average as the class name.Powerpoint TemplatesPage #
3. Create a program that will get the product of 18 and 15. Then display the result.
Use Product as the class name.Powerpoint TemplatesPage #
4. Create a program that will get the quotient of 185 and 13. Then display the result.
Use Quotient as the class name.Powerpoint TemplatesPage #public class Difference{public static void main (String[]args) {int num1=150;int num2=75;int difference;
difference=num1-num2;System.out.println(The difference is: +difference); }}
Powerpoint TemplatesPage #The difference is 75.Powerpoint TemplatesPage #public class Average{public static void main (String[]args) {int num1=35;int num2=42;int num3=23;double ave;
ave=(num1+num2+num3)/3;System.out.println(The average is: +ave); }}
Powerpoint TemplatesPage #The average is 33.33Powerpoint TemplatesPage #public class Product{public static void main (String[]args) {int num1=18;int num2=15;int product;product=num1*num2;System.out.println(The average is: +product); }}
Powerpoint TemplatesPage #The product is 270.Powerpoint TemplatesPage #public class Quotient{public static void main (String[]args) {int num1=185;int num2=13;int quotient;quotient=num1/num2;System.out.println(The quotient is: +quotient); }}
Powerpoint TemplatesPage #The quotient is 14.23Powerpoint TemplatesPage #public class Sample{ public static void main (String [] args) { System.out.println(Melanie Cruz);}}
Powerpoint TemplatesPage #