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

Slides:



Advertisements
Similar presentations
1 pritisajja.info Unlocking the World of Java Programming….. Priti Srinivas Sajja February, 2014 Visit pritisajja.info for detail Future Technology for.
Advertisements

Types, Variables and Operators Computer Engineering Department Java Course Asst. Prof. Dr. Ahmet Sayar Kocaeli University - Fall 2013.
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
Lecture 2 Introduction to C Programming
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Chapter 1: Introduction
1 Java Basics. 2 Compiling A “compiler” is a program that translates from one language to another Typically from easy-to-read to fast-to-run e.g. from.
Outline Java program structure Basic program elements
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
Variables, Data Types, & Arithmetic Expressions CSC 1401: Introduction to Programming with Java Lecture 3 Wanda M. Kunkle.
Java An introduction. Example 1 public class Example1 { public static void main (String [] args) { System.out.println (“This is the first example”); int.
Fundamental Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
Chapter 2: Introduction to C++.
COMP 14: Primitive Data and Objects May 24, 2000 Nick Vallidis.
1 The First Step Learning objectives write Java programs that display text on the screen. distinguish between the eight built-in scalar types of Java;
By: Mr. Baha Hanene Chapter 3. Learning Outcomes We will cover the learning outcome 02 in this chapter i.e. Use basic data-types and input / output in.
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
Java Language and SW Dev’t
Chapter 2: Basic Elements of Java J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
Introduction to Java Thanks to Dan Lunney (SHS). Java Basics File names The “main” method Output to screen Escape Sequence – Special Characters format()
Chapter 2 Basic Elements of Java. Chapter Objectives Become familiar with the basic components of a Java program, including methods, special symbols,
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
The Java Programming Language
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
CSE 1301 Lecture 2 Data Types Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
JAVA Tokens. Introduction A token is an individual element in a program. More than one token can appear in a single line separated by white spaces.
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
Chapter 2: Java Fundamentals
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
Java Programming: From Problem Analysis to Program Design, 5e Chapter 2 Basic Elements of Java.
FIRST JAVA PROGRAM. JAVA PROGRAMS Every program may consist of 1 or more classes. Syntax of a class: Each class can contain 1 or more methods. public.
Using Data Within a Program Chapter 2.  Classes  Methods  Statements  Modifiers  Identifiers.
Introduction to programming in the Java programming language.
1 Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
© 2004 Pearson Addison-Wesley. All rights reserved ComS 207: Programming I Instructor: Alexander Stoytchev
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
Identifiers.
A Simple Java Program //This program prints Welcome to Java! public class Welcome { public static void main(String[] args) { public static void main(String[]
Developed at Sun Microsystems in 1991 James Gosling, initially named “OAK” Formally announced java in 1995 Object oriented and cant write procedural.
By Mr. Muhammad Pervez Akhtar
CSM-Java Programming-I Spring,2005 Fundamental Data Types Lesson - 2.
Java Programming: From Problem Analysis to Program Design, Second Edition 1 Lecture 1 Objectives  Become familiar with the basic components of a Java.
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
CS 106 Introduction to Computer Science I 01 / 24 / 2007 Instructor: Michael Eckmann.
Chapter 3 Introducing Java. Objectives and Goals 1. Define terminology associated with object- oriented programming. 2. Explain why Java is a widely used.
Copyright 2010 by Pearson Education APCS Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
2.1 The Part of a C++ Program. The Parts of a C++ Program // sample C++ program #include using namespace std; int main() { cout
Java Programming: Guided Learning with Early Objects Chapter 1 Basic Elements of Java.
C++ First Steps.
Chapter 6 JavaScript: Introduction to Scripting
Working with Java.
BASIC ELEMENTS OF A COMPUTER PROGRAM
Lecture 2 Data Types Richard Gesick.
CS180 – Week 1 Lecture 3: Foundation Ismail abumuhfouz.
Data types and variables
Java Programming: From Problem Analysis to Program Design, 4e
Statements, Comments & Simple Arithmetic
Chapter 2: Basic Elements of Java
Java Tutotrial for [NLP-AI] 2
Chapter 2: Java Fundamentals
Expressions and Assignment
elementary programming
Anatomy of a Java Program
Fundamental OOP Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
In this class, we will cover:
JAVA. Java is a high-level programming language originally developed by Sun Microsystems and released in Java runs on a variety of platforms, such.
Presentation transcript:

Agenda Comments Identifiers Keywords Syntax and Symentics Indentation Variables Datatype Operator

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?

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 }

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*/ }

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.

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

Identifiers Variables Methods Classes

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.

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

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().

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”); }

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

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

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”);}}

Platform Independent

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

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

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.

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”;

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

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

Truth tables

Any Questions??

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.