Presentation is loading. Please wait.

Presentation is loading. Please wait.

Agenda Comments Identifiers Keywords Syntax and Symentics Indentation Variables Datatype Operator.

Similar presentations


Presentation on theme: "Agenda Comments Identifiers Keywords Syntax and Symentics Indentation Variables Datatype Operator."— Presentation transcript:

1

2 Agenda Comments Identifiers Keywords Syntax and Symentics Indentation Variables Datatype Operator

3 Comments Comments are used for documenting the program. The compiler simply ignores the comments. Comments don't have any effect in the execution of the program. What is obvious today may not be obvious after sometime. What if someone else wants to read your codes?

4 Types of Comments Single line comments: reaches till the end of the line only package test // package declaration public class Hello { public static void main (String [] args) // main method { System.out.println(“Hello World”); //print statement }

5 Multi-line comments: comments that reach more than one line class Hello // class is a keyword. All keywords should be in small letter { public static void main (String args[]) //public is a key word { System.out.println(“Hello World”); /*Hello World is a string value which should be enclosed in double quotation marks.*/ } /*compiler needs to know when the body of the scope has been started and ended. Unable to specify opening and closing of scope will give error message*/ }

6 Doc (document) Comment Document comment generally known as doc comment is special kind of multi line comment. Whenever doc comment are written; compiler generates separate HTML file where there is description of the comments of that particular things.

7 Identifiers Identifiers are combination of words, numbers and symbols used for naming classes, methods and variables Hello is identifier in the previous example. Identifiers consists of letters, digits and two characters '_' and '$‘ Eg: first_name, $city

8 Identifiers Variables Methods Classes

9 Rules for identifiers Identifiers cannot start with digits E.g. 1name is wrong Identifiers should not contain spaces E.g. hello world Except $ and _ ; other symbols are not allowed while declaring identifier. E.g. #hello Reserved keywords are not allowed for declaring identifiers. E.g. public Note : Java is case sensitive so, “Name”, “NAME” and “name” are three different terms.

10 Keywords In JAVA; certain words are reserved for some special functionalities. Such words are called as keywords. For E.g. class Hello // class is a keyword. All keywords should be in small letter { public static void main (String args[]) //public is a key word { System.out.println(“Hello World”); /*Hello World is a string value which should be enclosed in double quotation marks.*/ } /*compiler needs to know when the body of the scope has been started and ended. Unable to specify opening and closing of scope will give error message*/ } Keywords class public static void

11

12 JAVA class Library Java class library – contains methods already defined by Java. E.g. println() These methods have specific functions. println( ) prints the argument on the screen. E.g. System.out.println(“Hello world”);prints “Hello world” in the new line of screen. There are thousands of predefined methods: sin(), sqrt(), compareTo().

13 Syntax Syntax is a grammatical rule to write a programs. E.g. class Hello { public static void main (String args[]) { System.out.println(“Hello World”); } Hello { public static void main (String args[]) { System.out.println(“Hello World”); }

14 Semantics Semantics refers to the meaning of the program. E.g. class Hello { public static void main (String args[]) { System.out.println(“Hello World”); }

15 Two programs written in different languages could do the same thing (semantics) but the symbols used to write the program would be different (syntax). System.out.print(“Hello World); // JAVA echo(“Hello World”); // PhP Console.Write(“Hello World”); // C#.NET

16 Indentation Proper tabbing to group similar elements together public class Hello { public static void main(String [ ]args) { System.out.println(“Hello World”); } Makes the code much easier to understand. public class Hello{public static void main(String[]args){System.out.printl n(“Hello World”);}}

17 Platform Independent

18 Variables Variable is a container that holds value temporarily which value can be changed while writing a program. E.g. String color = “red”;

19 Data Types Data type is a set of data having some value with predefined characteristics. E.g. int a = 5;

20 Types of Data Types Primitive Data Types Primitive data types are predefined types of data, which are supported by the programming language. For example, integer, character, and floating type are all primitive data types. Reference Data Types Reference Data Types are those types which exists with the combination of primitive data types. For example, arrays, class etc.

21 Operator An operator is a sign or symbol which performs some operations between one or multiple operands. For example, int a = 5 +3; a++; string message = “Hello” + “World”;

22 Types of Operator 1.Arithmetic Operators E.g. +, -, *, /, % 2. Assignment Operators E.g. = 3. Relational/Comparison Operators E.g. >, >=, <, <=, !=, ==

23 4. Logical Operators E.g. &&, ||, ! 5. Increment / Decrement Operator E.g. ++, --

24 Truth tables

25 Any Questions??

26 Notice Student should make a separate notebook for “INTRODUCTION TO PROGRAMMING”. It must be with the student during the formal classes LTW. If any student fail to bring the notebook they will penalized by deducting 5 marks in each class.


Download ppt "Agenda Comments Identifiers Keywords Syntax and Symentics Indentation Variables Datatype Operator."

Similar presentations


Ads by Google