You are on page 1of 17

CO_IF_22412_CO1

Ms. Yogita Jore, Head of Information Technology, Vidyalankar Polytechnic

Date: 07th February 2021

Learning at your doorstep


Unit 1:
Basic Syntactical constructs in Java

Written by

Yogita Jore
Head, Department of Information Technology (NBA Accredited),
Vidyalankar Polytechnic, Mumbai
Unit Outcome 2:
Explain the characteristics of the given
Java Token.
Learning Outcome 2:
Student should understand
characteristics of the given Java Token.
What we will learn today

1. Token and Data Type Key takeaways


2. Dynamic Initialization Understand the concept of Tokens in java.

3. Array and String

Yogita Jore
Head, Department of Information Technology (NBA Accredited), Vidyalankar Polytechnic,
Mumbai

Page 5 Maharashtra State Board of Technical Education


Concept Map

Page 6 Maharashtra State Board of Technical Education


Learning Objective/ Key learning

► Learn Java Token:


 Keyword
 Constant
 Identifier
 String
 Special Symbol
 Operators

► Data Types
► Dynamic Initialization
► Concept of Array and String

Page 7 Maharashtra State Board of Technical Education


Java Token

 A token is the smallest element of a program that is meaningful to the compiler.


Token Meaning Example

Keyword A variable is a meaningful name of data storage location in computer memory. int continue
When using a variable you refer to memory address of computer. break public
return do
while for
Constant Constants are expressions with a fixed value. They are also called as literals final int a=20;
Syntax: final data_type variable_name;

Identifier Identifiers are the names of variables, methods, classes, packages and MYVARIABLE
interfaces. _myvariable
$myvariable
_9pins
andros
??????
String Sequence of characters. char[] ch={'a','t','n','y','l','a'};

String s=new String(ch);


Special Symbol Symbols other than the Alphabets and Digits and white-spaces. [] () {}, ; * =

Page 8 Maharashtra State Board of Technical Education


Operators A symbol that represents a specific mathematical or non-mathematical action. / + == ?
Keyword:

Java keywords cannot be used as identifiers.

Page 9 Maharashtra State Board of Technical Education


Constant/Literals:

Constants/Literals is an identifier whose value is fixed and does not change during the execution of the
program.

Page 10 Maharashtra State Board of Technical Education


Data Types:

 Data types specify the different sizes and values that can be stored in the variable..

Page 11 Maharashtra State Board of Technical Education


Variables:

 A variable is a container which holds the value while the Java program is executed.
 A variable is assigned with a data type.
 Variable is a name of memory location.
 Rules for naming variable:

Page 12 Maharashtra State Board of Technical Education


Variable Declaration and initialization:

Page 13 Maharashtra State Board of Technical Education


Types/Scope of Variables :

Local Instance Class/ Static


• A variable that is • A variable that is • A variable that is
declared inside the declared inside the declared as static is
method is called class but outside the called as Class/ Static
Local Variable. method is called variable.
instance variable.

Page 14 Maharashtra State Board of Technical Education


Dynamic Initialization:

 Initializing a variable at run time is called dynamic initialization.


 Java allows variables to be initialized dynamically, using any expression valid at the time the variable is declared.

Page 15 Maharashtra State Board of Technical Education


Array and String:

 Array:
 An array is a collection of similar types of data.
 For example,
if we want to store the names of 100 people then we can create an array of the
string type that can store 100 names.
Syntax: datatype[ ] arrayname;
Example: double[ ] percentage;

 In Java, we can initialize arrays during declaration. For Example: int[ ] age={12,4,5,2,5};

 String:
 String is basically an object that represents sequence of char values. For example:
 An array of characters works same as Java string. char[] ch={‘M’,’S’,’B’,’T’,’E’};
String s=new String(ch);

Page 16 Maharashtra State Board of Technical Education


Problem/ Question Explanation and step by step Solution

Q1:What are the categories of data types?


Ans: Primitive and non- primitive

Q2: ____ are expressions with a fixed value.


Ans: Constants

Page 17 Maharashtra State Board of Technical Education

You might also like