The document covers the concepts of values and data types in programming, focusing on character sets like ASCII and Unicode, as well as tokens in Java. It explains ASCII's character values, how to use ASCII in Java, and introduces Unicode as a broader character set. Additionally, it discusses keywords, their significance, and case sensitivity in Java programming.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
1 views4 pages
03 01 CharSetTokensKeywords
The document covers the concepts of values and data types in programming, focusing on character sets like ASCII and Unicode, as well as tokens in Java. It explains ASCII's character values, how to use ASCII in Java, and introduces Unicode as a broader character set. Additionally, it discusses keywords, their significance, and case sensitivity in Java programming.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4
Class IX Chapter 3
Values and Data Types: 1, 2 & 3
Extract From Syllabus: 3. Values and data types Character Set: ASCII code, Unicode Tokens and its Types: Keywords …… Lesson 1 Character Set Character set is a set of valid characters that a language can recognize. E.g.: A b c d are valid character set of English language. Special characters such as ? , . + - * etc and digits 0,1, 2,3 etc also valid characters of English language. Computer Character Sets Computer language also two character sets.These are ASCII and Unicode. ASCII The basic computer character set is ASCII. Full form of ASCII is American Standard Code for Information Interchange. There are 256 characters in ASCII. ASCII Characters and Values: A 65 B 66 … Z 90 a 97 b 98 … z 122 0 48 1 49 … 9 57 space 32 Other numeric values are for special characters and some symbols. ASCII in Java When a character stores into an integer variable it results its ASCII number. E.g.: int x = ‘A’; System.out.println(x); The output is 65. When an integer value stores into a char variable it results its ASCII character. E.g.: char y = 66; System.out.println(y); The output is B. Write output: int n='a'; char c=98; int x=‘1’; System.out.println(n); System.out.println(c); System.out.println(x); Output: 97 b 49 Unicode The character set of Java is Unicode. It is a two byte character code set. It consists alphabets of English, Malayalam, Hindi, Tamil, German, Arabic etc. i.e., characters of almost all human languages. There are 65536 characters in Unicode. Unicode is written by using \u followed by a four digit number in single quotes. The Unicode for A is ‘\u0041’. The System.out.println('\u0041'); results A. The Unicode for a is ‘\u0061’. The System.out.println('\u0061'); results a. Raju Xavier | 9446748197 | www.rajuxavier.org 1 Values and Data Types ICSE IX 2 Values and Data Types Write output: System.out.println('\u0042'); System.out.println('\u0063'); Answer: B c Answer the following: 1) ASCII value of 2 2) ASCII value of ‘ ’ (space) Answer: 1) 50 2) 32 Answer the following: 1) Number of characters in ASCII 2) Number of characters in Unicode Answer: 1) 256 2) 65536
Not for exam; only for knowledge:
Use of ASCII Programs are typed in English. To convert English into computer language, i.e, machine language (binary digits 0 and 1) it requires some numbers. These numbers are ASCII values and Unicode values. The letter A is an ASCII character and 65 is its ASCII value. From this 65 the binary 1000001 is derived. (Reverse of remainders when 65 is divided by 2 till quotient becomes 0).
Not for exam; only for knowledge:
Decimal to Binary Conversion of ‘A’: To store A into computer memory 2 65 2 32 1 2 16 0 2 8 0 2 4 0 2 2 0 2 1 0 0 1 6510 = 10000012 (Binary of A) Decimal to Binary Conversion of ‘B’: To store B into computer memory 2 66 2 33 0 2 16 1 2 8 0 2 4 0 2 2 0 2 1 0 0 1 6610 = 10000102 (Binary of B)
Raju Xavier | 9446748197 | www.rajuxavier.org 2 Values and Data Types
Values and Data Types 3 ICSE X Lesson 2 Tokens in General The smallest individual unit in a program is known as a token. A token is formed by one or more valid characters. Keywords, Identifiers, Literals, Punctuators and Operators (KILPO) are tokens in Java. Meaningful combination of tokens is known as statements; in other words statements are formed with tokens. E.g.: int a=5, b=3; int s=a+b; 1. Identify the tokens in the statement given below: int a=5,b=3; Answer: int Keyword a b Identifiers = Operator 5 3 Literals , ; Punctuators / Separators 2. Identify the tokens in the following: public class Sum { } Answer: class Keyword Sum Identifier (name of the class) {} Punctuator / Separator 3. Identify the tokens in the following: public static void main() Answer: public static void Keywords main Identifier (name of a method) () Punctuator / Separator 4. Identify the tokens in the following: System.out.println(“Hello”); Answer: System.out.println Identifier (Pre-defined method name) “Hello” Literal (String literal) . () ; Punctuators / Separators 5. Identify the tokens in the following: String s=“Aneena”; Answer: String Identifier (Pre-defined class name) s Identifier (User-defined variable name) = Operator “Aneena” Literal (String literal) ; Punctuator / Separator
Values and Data types 3 Raju Xavier | 9446748197 | www.rajuxavier.org
ICSE IX 4 Values and Data Types Lesson 3 Keywords Keywords are words that convey special meaning to the compiler. They are reserved for special uses. Keywords should not be used as identifiers (class name, method name, variable name, object name etc.) Keywords are used to describe identifiers. E.g.: class Sum. The class is a keyword and the Sum is an identifier. It describes that the Sum is a class. The class is shortform of classification i.e, category, group etc. The int a means (describes) that the type of variable a is int (int means integer) Answer the following: Name the keyword to determine that a class can be executed by any other class public Name the keyword to define a class class Name the three essential keywords to define main() method public static void Name the keyword used to declare integer data type variable to store up to 2 billion. int Name the keyword to declare real data type variable to store up to 17 digits. (numbers with decimal point) double Name the keyword used to declare a character data type for a variable. char Case Sensitivity Case means uppercase (capital letters) and lowercase (small letters). Java considers capital letters and small letters are different. If we write a keyword as Public, as the P is capital letter Java cannot recognize it as a keyword. Keywords should be always in small letters. Correct the errors: Public class Sum Int sum=5+3; Double d=3.5*2; Answer: public class Sum //public is a keyword. The p should be in small letter int sum=5+3; //int is a keyword. The i should be in small letter double d=3.5*2; //double is a keyword. The d should be in small letter Correct the errors: String class=“9 A”; int double=b*2; Answer: String Class=“9 A”; //C of Class is capital. So it is not a keyword int Double= b*2; //D of Double is capital. So it is not a keyword
Raju Xavier | 9446748197 | www.rajuxavier.org 4 Values and Data Types