Presentation is loading. Please wait.

Presentation is loading. Please wait.

Welcome to Java. 2  History of java  Advantages of java  Java first program  Rules to be followed  Data types  Operators  Casting  Control statements.

Similar presentations


Presentation on theme: "Welcome to Java. 2  History of java  Advantages of java  Java first program  Rules to be followed  Data types  Operators  Casting  Control statements."— Presentation transcript:

1 Welcome to Java

2 2  History of java  Advantages of java  Java first program  Rules to be followed  Data types  Operators  Casting  Control statements  Taking input from keyboard  Arrays  Strings  String buffer and string builder  Oops concepts  Access specifiers  Constructors  Different types of methods  This Keyword contents

3 3 Contents continued  Interface and package  Threads  Exception handling  Graphical programming  Awt  Swings  Applet

4 4 This is java tutorial from Java Bean this is the demo version of first class In this tutorial we are going to learn the basic foundations required to learn java Before getting into java the first question comes to mind is Is java tough ?

5 5 Definitely not ! If yes then how we understand other languages like English, Hindi although our mother tongue may be different how we learnt those languages We had certain basic foundation through which we Started learning We started with alphabets A B C D grouped these alphabets to form words.we grouped these words to form sentence These sentences are used as communication bridge to talk and understand others talk

6 6 Similarly we can learn java.here also we have alphabets known as variables, words known as keywords statements known as syntax By using these syntax we can communicate to computer to perform task

7 7 Before stepping into java,basic knowledge of C& C++ is needed as they are the foundation on which java is been designed If you don’t have no need to worry in this tutorial required knowledge of C & C++ is covered Let us begin Java with C program….hello word to know the meaning of Syntax(So called statements)

8 8 #include main() { printf("Hello World"); } Simple Hello world Program

9 9 # means preprocessor directives As a name says which are processed before, The C preprocessor modifies a source file before handing it over to the compilerC preprocessor Or we can say pre written, Include is simple including of pre written function definition is a label where the definition of function are Stored

10 10 Don’t be confused now we will understand where #include will come into picture In last slide I was talking about function definition Basically there are 2 types of functions 1.Predefined 2.Userdefined Function is defined as set(group) of syntax performing specific task

11 11 Basically function as two parts Function prototype(head) Function body(defination) add()…………………….function prototype(head) { …………. ………… ………. } Function body

12 12 function prototype: Says what I am going to do function definition: Says what task I am doing When we consider our above program we have to functions main() printf()

13 13 #include main()……………………..no semicolon { printf("Hello World"); …….semicolon } What difference you can notice between main and printf When function has no semicolon it is followed by { and ended with } Which means head and body exist

14 14 Main : is the function where execution starts After main exection goes to printf(); where no defination is found so compiler goes to library search for label inside which it search for printf defination When defination is found it copies the entire code from library to program and execute it

15 15 add()…………………….function prototype(head) { …………. ………… ………. } Function can only executed if it has both head and body Then in case of printf(); where is the body,if no body how can it run Function body

16 16 Regular used functions definition are pre written and are stored in library which at the start of the program we are including Since there are lot of predefined functions they categorized by labels In these blocks respective function definitions are stored Similarly the function defined by us are called as user defined function

17 17 #include main() { printf("Hello World"); } C library Stdio.h Conio.h Math.h definition

18 18 The reason to start with c program was just to know the meaning Of the words what we use in program, when we know the meaning of the syntax,programs are easy to learn now it’s a time to know how java came into existence and why it has become so important Although we have c and c++,why java came into existance ? Where c and c++ fail……..?

19 19 C and C++ failed due to platform dependencies Platform is base where we run program, platform is combination of operating System and Processor Win 7 os Win 7 os keyboard I3 process or platform

20 20 When we write C program in operating system and processor,it can be re runned in only in same operating system and processor For example if I write program in win7 nd p4 processor it can be runned again in the same,if I try to run in different os and processor like win7 and i5,it fails to run Why c and c++ fail to run…?

21 21 case 1 Win7 P4 Add.c case 1 Win7 P4 Add.c case 2 Win7 I3 Add.c Add.obj Add.exe Compile run Compile run Why it is not running…………?

22 22 Lets know the reason When we write c program we save with the extension.c Add.c This is source code When we compile c program we get the extension.obj Add.obj This is machine code(object code) This machine code always depends upon processor and operating System

23 23 case 1 Win7 P4 Add.c case 1 Win7 P4 Add.c Add.obj Add.exe Compile run Let us consider Case 1 Os:-win 7 Process:p4 When we compiles Add.c For adding of two numbers Machine codeformat we get Add A,B

24 case 2 Win7 I3 Add.c Add.obj Add.exe Compile run When we consider case 2 Os:win7 Process:i3 When we compiles Add.c For adding of two numbers Machine codeformat we get A ADD B

25 25 Now we try to take code of case 1 after compiling and pate to run in case 2 Case 1 lang:ADD A,B Case 2 lang:A ADD B Case 2 cannot recognize case 1 language hence it cannot run This made c and c++ failure Since all systems cannot have same os and processor it is platform dependent

26 26 Being a software developer we want our application(program) to be used by all in such a case it should be recognized by all the system This made the invention of java

27 27 History of java Gosling is founder of Java programming language in 1994 it was named as oak Java In January 1995 it was renamed as java since was already registered Its platform independent pure object oriented if we write once we can run anywhere

28 28 Import java.io.* public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World"); } Simple java Program

29 29 Before we enter in depth lets see how it was made platform Independent Saving java program:Example.java After compiling Example.class Class code is not machine code like c,it is called as Byte code

30 30 Byte code is a intermediate code which is nither source code nor machine code Problem was machine code reason if we convert to Machine code only that machine can understand This code is given to converter (jvm) which converts to machine language depending on machine Hence depending on machines there are flavors of jvm

31 31 Let us consider example Person A Knows only english Person B Knows english/frenc h Person c Knows only French

32 32 Similar Thing happens in java This is how java is platform independent jvm

33 33  Advantages of java  Java first program  Rules to be followed This is it For First class We shall continue next class with below topics


Download ppt "Welcome to Java. 2  History of java  Advantages of java  Java first program  Rules to be followed  Data types  Operators  Casting  Control statements."

Similar presentations


Ads by Google