O slideshow foi denunciado.
Seu SlideShare está sendo baixado. ×

Introduction to Java Programming, Basic Structure, variables Data type, input & output

Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Próximos SlideShares
Introduction to java
Introduction to java
Carregando em…3
×

Confira estes a seguir

1 de 45 Anúncio

Introduction to Java Programming, Basic Structure, variables Data type, input & output

This is First Lecture of java Programming which cover all basic points (ie. History and feature of java, Introduction to java, about variables data type and compilation....

This is First Lecture of java Programming which cover all basic points (ie. History and feature of java, Introduction to java, about variables data type and compilation....

Anúncio
Anúncio

Mais Conteúdo rRelacionado

Diapositivos para si (20)

Semelhante a Introduction to Java Programming, Basic Structure, variables Data type, input & output (20)

Anúncio

Mais recentes (20)

Introduction to Java Programming, Basic Structure, variables Data type, input & output

  1. 1. 1 Mr. Akaash akaashhakim@gmail.com Java: Introduction Basic Structure, variables Data type, input & output
  2. 2. 2 Why Java is developed.  Sun Microsystems ins. Develop deferent software for deferent devices. Even the work of these soft wares is same.  If they want to run this software on others platform that is not possible. then They must have to write deferent program. They write this program in c/C++.  Then they release that we reduce this effort only if they Develop a platform independent language. (Means: Program is written on a platform then it execute on any platform)  What is platform? Platform is a environment in that the software is executed. For we example. In our computer the software is only run because in our computers one software is already executed. This software is Operating system.
  3. 3. 3 Why Java is developed.  Operating system works as a platform for those programs that we want to execute.  Without operating system we can't run any program  If any program is execute of deferent operating system then we call it platform independent software  For this purpose Sun Microsystems Inc. want to develop a java language  In earlier java is developed as a solution of an problem.
  4. 4. 4 Introduction of JAVA  Originally created for consumer electronics (TV, VCR, Freeze, Washing Machine, Mobile Phone).  Java - CPU Independent language  Internet and Web was just emerging, so Sun turned it into a language of Internet Programming.  It allows you to publish a webpage with Java code in it.
  5. 5. 5 History of Java  Java Language is developed in 1991 in the form of a project.  Java Programming Language was written by James Gosling along with two other person 'Mike Sheridan' and 'Patrick Naughton', while they were working at Sun Microsystems Inc.  In earlier Sum Microsystems Inc. want to register this language with the name OAK language. OAK is the name of tree which is placed out side the office of James Gosling  Later the project went by the name Green and was finally renamed Java, from Java coffee Java developer James Gosling
  6. 6. 6 History of Java  Java was originally designed for interactive television, but it was too advanced for the digital cable television industry at the time  Gosling designed Java with a C/C++-style syntax that system and application programmers would find familiar
  7. 7. 7 History of java  On January 27, 2010. java Sun Microsystems Inc. acquired by Oracle corporation for US$ 7.4 Billon.
  8. 8. 8 Java is everywhere  JAVA resides in mobiles, client machines, server machines, embedded devices, smart phones, cloud etc.  It Shares same basic features of the language and libraries  Principle of JAVA: WORA (Write Once, Run Anywhere)
  9. 9. 9 What is Library  What is library in C/C++?  We can say that in C/C++ collection of predefined function is called C Library  Java Library is a collection of predefined classes. Like a C/C++.
  10. 10. 10 Version history of JAVA
  11. 11. 11 There were nine primary goals in the creation of the Java language:  Simple  Object Oriented Programming  Distributed  Interpreted  Robust  Secure
  12. 12. 12 Explanation of Feature of JAVA  Object-Oriented Programming  Object-oriented programming (OOP) is a programming language model organized around objects rather than "actions" and data rather than logic. Historically, a program has been viewed as a logical procedure that takes input data, processes it, and produces output data  Distributed  Distributed Java Programming with RMI and CORBA. ... The Java Remote Method Invocation (RMI) mechanism and the Common Object Request Broker Architecture (CORBA) are the two most important and widely used distributed object systems. Each system has its own features and shortcomings.
  13. 13. 13 Explanation of Feature of JAVA  Interpreted  Java is a compiled programming language, but rather than compile straight to executable machine code, it compiles to an intermediate binary form called JVM byte code. The byte code is then compiled and/or interpreted to run the program.  Robust  Java is Robust because it is highly supported language. It is portable across many Operating systems. Java also has feature of Automatic memory management and garbage collection. Strong type checking mechanism of Java also helps in making Java Robust. Bugs, especially system crashing bugs, are very rare in Java
  14. 14. 14 Explanation of Feature of JAVA  Secure  Vulnerabilities in the protection mechanisms provided by the hardware or operating system which the application relies upon for its security. Vulnerabilities in native libraries, such as the C standard library, which may be used to implement the application and/or runtime  Portable  "Java is portable" refers to the SE version. It means that you can run Java byte code on any hardware that has a compliant JVM. It doesn't mean that ME is the same as SE is the same as EE.
  15. 15. 15 Explanation of Feature of JAVA  Multithreaded  The main purpose of multithreading is to provide simultaneous execution of two or more parts of a program to maximum utilize the CPU time. A multithreaded program contains two or more parts that can run concurrently. ... RUNNABLE – A thread executing in the Java virtual machine is in this state.  Garbage collector  The garbage collector is a program which runs on the Java Virtual Machine which gets rid of objects which are not being used by a Java application anymore. It is a form of automatic memory management
  16. 16. 16 How to Compile Java Program When we compile .Java file it create .class file C/C++ compilers convert C/C++ code in these language which Operating System Understand… But the JAVA Compiler convert JAVA code into Byte code. Operating System can’t understand this code. If .java file has 5 classes then JAVA compiler create five deferent class files.…
  17. 17. 17 Practical of Compile java program  Firstly we write our java program in notepad  Then save this code with .java extension in bin folder This bin folderThis bin folder Saving hello program with .java extension Saving hello program with .java extension
  18. 18. 18 Before compile Java program there is no .class file created Before compile Java program there is no .class file created javac is java compiler that convert java code to byte code javac is java compiler that convert java code to byte code It is java codeIt is java code After compile the java code java compiler create .class file After compile the java code java compiler create .class file
  19. 19. 19 How Run JAVA Program For run java program: We install JVM(JAVA Virtual Machine) we can run our Byte code file with the help of JVM JVM is the Operating System dependent program. This is JVM that execute the This is .class file we don’t have to need write its extension Output
  20. 20. 20 Java is Compiled and Interpreted Text Editor Compiler Interpreter Programmer Source Code .java file Byte Code .class file Hardware and Operating System Notepad etc. javac java appletviewer netscape
  21. 21. 21 JAVA Virtual Machine  JVM is the platform dependent  The JAVA Virtual Machine provides the platform-independent way to execute JAVA code .  Java Virtual Machine interprets the byte code into the machine code depending upon the underlying operating system and hardware combination
  22. 22. 22 Total Platform Independence JAVA COMPILERJAVA COMPILER JAVA BYTE CODEJAVA BYTE CODE JAVA INTERPRETERJAVA INTERPRETER Windows 95 Macintosh Solaris Windows NT (translator) (same for all platforms) (one for each different system)
  23. 23. 23 JAVA  Java is case sensitive language like C/C+ +.  Java is nearly 100% Object-oriented language.  In java it is not possible to make a function which is not member of any class (as we do C/C++)
  24. 24. 24 NO , Java is 99% oop . Remaining 1% ????????? Java 100% OOP??? Reason Primitive Data Types
  25. 25. 25 Primitive Data Types Wrapper Classes 1.byte Byte 2.int Integer 3.short Short 4.long Long 5.float Float 6.double Double 7.char Character 8.boolean Boolean Data Type & Wrapper classes
  26. 26. 26 Java Applications  We can develop two types of Java programs:  Stand-alone applications  Web applications (applets)
  27. 27. 27 Java better than C++ ?  No Typedefs, Defines, or Preprocessor  No Global Variables  No Goto statements  No Pointers  No Unsafe Structures  No Multiple Inheritance  No Operator Overloading  No Automatic Coercions  No Fragile Data Types ?
  28. 28. 28 Object Oriented Languages -A Comparison Feature C++ Objective C Ada Java Encapsulation Yes Yes Yes Yes Inheritance Yes Yes No Yes Multiple Inherit. Yes Yes No No Polymorphism Yes Yes Yes Yes Binding (Early or Late) Both Both Early Late Concurrency Poor Poor Difficult Yes Garbage Collection No Yes No Yes Genericity Yes No Yes Limited Class Libraries Yes Yes Limited Yes
  29. 29. 29 Basic Structure that almost use in every java program Wrapper Class Main MethodMain Method Class NameClass Name Package Name Body of Main methodBody of Main method Java Application Save with class name and .java extension Java Application Save with class name and .java extension Public keyword specified that main() function accessible outside the class The void specifies means that main() does not return any values Static keyword specified that main() exists without any object be defined The outer class may a public or default The inner class may a public private, protected or default
  30. 30. 30 Short Detail of previous Image  Package:-  A package have many classes Same type of classes are store in same package.  Public:-  The Public keyword specified that main() function accessible outside the class  Class Name:-  Class name is user define.  Class:-  is Keyword that is optional.  Static:-  The Static keyword specified that main() exists without any object be defined  Void main:-  Main Method  String[]:-  Wrapper Class  Arg:-  Arguments
  31. 31. 31 Variable in Java  Variable is used to access data .  We use variable to store data.  Variable use for get input from user.  Variable used for give output to user.
  32. 32. 32 Variable Declaration  We declare a variable in java same as in C++.  Syntax: Data_type variable_name;  DataTypes:  Data_types used for defined type of variable for example you store (10) integer data. We use int data type.  Varible_name:  Variable name is user defined. we can declare variable name following variable declaration rules
  33. 33. 33 Data Types  Data Types that define which type of value used in program  There are many data types of java  Integer Data types Declaration of integer Variable Data_types Variablename;
  34. 34. 34 Data types  Floating Data types Declaration of Floating Variable Data_types Variablename;
  35. 35. 35 Java Output We use “System.out.println()” for print any message or result on screen. System.out.println(“ “) This is the name of class that contains the object out This is the name of class that contains the object out This is a static variable that in system class This is a static variable that in system class This a method in object out Whatever you specify between parenthesis () is passed to the println( ) method and displayed
  36. 36. 36 System.out.println(); System.out.println(); It is used to display message, result and Message+Result. System is a class that is in java.lang package. Java.lang package by default import in netbean IDE. In println() method, “ln” use for new line.
  37. 37. 37 System.out.println()  It used for 3 purpose “Message” , ”Result” and “Message + result” System.out.println(); Message Result Message + Result
  38. 38. 38 System.out.println()/print(); Message Write Message in Double Quotes(” ”). Message Display as it we Write in Double Quotes.
  39. 39. 39 System.out.println()/print(); Result Write Result in without Double Quotes(” ”). What is 15? Sum of two numbers? OR Product of two numbers?
  40. 40. 40 System.out.println()/print(); Message+Result Write Message in Double Quotes(” ”). Write Result in without Double Quotes(” ”). For concatenation Message and result use plus(+) operator. Message Result OutputConcate.. .
  41. 41. 41 System.out.println()/print(); Message Result OutPutConcate.. .
  42. 42. 42 Input in Java  For input in java  We import a scanner  We create a scanner object  We use methods. Firstly import Scanner Create object Use methods It is class name Object name it is user defined It is Constructer For Integer Number More function
  43. 43. 43 More input methods
  44. 44. 44 Input program Output
  45. 45. 45 Code of previous Image package javaapplication6; import java.util.*; public class JavaApplication6 { public static void main(String[] args) { Scanner obj=new Scanner(System.in); int num1,num2; System.out.print("Enter first integer number ::"); num1=obj.nextInt(); System.out.print("Enter Second integer number ::"); num2=obj.nextInt(); System.out.println(num1+"+"+num2+"="+(num1+num2)); } }

×