chapter1 : java basics
TRANSCRIPT
![Page 1: Chapter1 : Java basics](https://reader036.vdocument.in/reader036/viewer/2022081122/589c4ea41a28ab227d8b6479/html5/thumbnails/1.jpg)
Subject : Advance Java (J2EE)
Class : SYMCA
Subject Teacher : Prof. V. V Shaga
![Page 2: Chapter1 : Java basics](https://reader036.vdocument.in/reader036/viewer/2022081122/589c4ea41a28ab227d8b6479/html5/thumbnails/2.jpg)
Unit-IJava Basics
![Page 3: Chapter1 : Java basics](https://reader036.vdocument.in/reader036/viewer/2022081122/589c4ea41a28ab227d8b6479/html5/thumbnails/3.jpg)
Contents
• Introduction• Java Buzzwords• Byte code• Sample Java Program• Type Conversion and Casting
![Page 4: Chapter1 : Java basics](https://reader036.vdocument.in/reader036/viewer/2022081122/589c4ea41a28ab227d8b6479/html5/thumbnails/4.jpg)
Introduction• JAVA is high level third generation
programming language• JAVA is a Platform for application development• JAVA derives much of its character from C and
C++• IDE’s for JAVA are :
Notepad,Notepad++,Jcreator, TextPad, DosEditor, Eclipse
![Page 5: Chapter1 : Java basics](https://reader036.vdocument.in/reader036/viewer/2022081122/589c4ea41a28ab227d8b6479/html5/thumbnails/5.jpg)
Java BuzzwordsSimple- C++ Programmers can move to java will require less efforts Secure- don’t instruct commands to the machine directly. Java program fully secured under the control of the JVMRobust -Platform Independent ,Object Oriented ,Programming Language, Memory management ,Exception HandlingMultithreaded - multiple task simultaneouslyArchitecture-neutral - developed and executed anytime in future. No effect of changing environments like hardware, processor, Operating system.
![Page 6: Chapter1 : Java basics](https://reader036.vdocument.in/reader036/viewer/2022081122/589c4ea41a28ab227d8b6479/html5/thumbnails/6.jpg)
Java BuzzwordsPortable - ability to run the program on any platform and no dependency on the underlying hardware Object-oriented - object oriented model in Java is simple and easy to extendInterpreted - JVM interprets the ByteCode into Machine instructions during runtime.High performance - interpret only the piece of the code that is required to execute and untouch the rest of the codeDistributed - Remote Method Invocation (RMI) using which a program can invoke method of another program across a network and get the output.Dynamic - update the pieces of libraries without affecting the code using it
![Page 7: Chapter1 : Java basics](https://reader036.vdocument.in/reader036/viewer/2022081122/589c4ea41a28ab227d8b6479/html5/thumbnails/7.jpg)
The Bytecode
• Not executable code• It is a highly optimized set of instructions
designed to be executed by the java run time system which is called JVM
![Page 8: Chapter1 : Java basics](https://reader036.vdocument.in/reader036/viewer/2022081122/589c4ea41a28ab227d8b6479/html5/thumbnails/8.jpg)
.Java file
JAVA Complier
BYTE CODE
.class file
JAVA VIRTUAL MACHINE
101010101
interpreted & executedby
Executable Machine Code
JIT Complier
101010101
![Page 9: Chapter1 : Java basics](https://reader036.vdocument.in/reader036/viewer/2022081122/589c4ea41a28ab227d8b6479/html5/thumbnails/9.jpg)
Sample Programclass First { public static void main(String args[]) { System.out.println(“welcome in java”); System.out.println(“This is simple java
program”); } }
![Page 10: Chapter1 : Java basics](https://reader036.vdocument.in/reader036/viewer/2022081122/589c4ea41a28ab227d8b6479/html5/thumbnails/10.jpg)
Assignment
1. Explain in detail java buzzwords.2. What is JVM? Explain the execution of java
program.3. Write the program to compute the area of circle.
Date : 04-Aug-2014Submission date : 11-Aug-2014
![Page 11: Chapter1 : Java basics](https://reader036.vdocument.in/reader036/viewer/2022081122/589c4ea41a28ab227d8b6479/html5/thumbnails/11.jpg)
Type Conversion and Casting• Implicit conversion(automatic conversion)– The two types are compatible– The destination type is larger than source
type. byteshortintlongfloatdouble
Java will automatically convert int expressions to double values without loss of informationint i = 5;double x = i + 10.5;
![Page 12: Chapter1 : Java basics](https://reader036.vdocument.in/reader036/viewer/2022081122/589c4ea41a28ab227d8b6479/html5/thumbnails/12.jpg)
Type Conversion and Casting• Explicit conversion– Two types are incompatible– Syntax for conversion : (target-type) value;double float longintshortbyte
Example :To convert double expressions to int requires a typecasting operation and truncation will occuri = (int) (10.3 * x)
![Page 13: Chapter1 : Java basics](https://reader036.vdocument.in/reader036/viewer/2022081122/589c4ea41a28ab227d8b6479/html5/thumbnails/13.jpg)
Some more Examples on Type-Casting..byte b;int i=257;double d=323.142;
1) Convert int to byte b=(byte)i; Ans = 1
2) Convert double to inti=(int)d; Ans= 323
3) Convert double to byteb=(byte)d;Ans = 67
![Page 14: Chapter1 : Java basics](https://reader036.vdocument.in/reader036/viewer/2022081122/589c4ea41a28ab227d8b6479/html5/thumbnails/14.jpg)
Assignments1.Write down about data types in
java. [Hint: write only how many bits,
range and its default value and example]
Eg:Short:It is 16 bit integer data type. Value range from -32768 to 32767. Default value zero. example: short s=11;