Sunday, 7 August 2016

Java Lecture Note

LECT - 1
Introduction
Programming knowledge
Expert in C and data structures
What is computer - electronic data processing machine.
Algorithms - finite sequence of mathematical  steps may or may not take some data as input and produces well defined outputs.
Programs - set of executable instructions written with respect to a particular programming language used to solve a particular problem.
Machine level language - compiler's native language
Assembly language - mnemonics that is low level language.
High level languages- English like languages.
You should be acquainted with some elementary programs like find area of triangle, Celsius to Fahrenheit, salary calculations.

Lecture-2
Programming languages. - Basic, FORTRAN,PASCAL, COBOL, - Relied upon GOTO
More structured language - C programming language, highly efficient that retains power of assembly level programming and high level languages.
Why we need other languages - Mange complexity becomes an important issue. This was addressed by. Another language C++, C with Object oriented concepts.
Why we need Java - motivation was a platform independent programming language needed for using in consumer electronic devices.
Problem in C/ C++ is that it compiled for a particular target machine. Hence Java eliminating the problem of using under different platforms. Since java is used for creating two types of programs i.e. applications and applets,it is applet for which it became extremely important for Internet.
Applications are programs that run under the os of the same machine
Applets  - are small programs that run under internet.
Java is very powerful fully featured language used for creating so many mission critical applications. Java was used for developing and controlling robotic ROVER that rolled on Mars.
History
1991 - James Gosling(head), Naughon at Sun Microsystems created language called OAK, later on renamed to JAVA.
1995- Microsoft announced source licence for java for using inside IE. Consequently Borland, Netscape, Mitsubishi, Sybase, Symantec applied for source license.
2010 - Oracle acquired JAVA.

LECT - 3 Monday 01 August 2016 10:40:08 PM IST
Java language specification
So now we start with java language specification.
API application program interface contains predefined classes and interfaces
SE - java comes with three edition , developing client side standalone applications
EE -server side applications
ME -micro edition for mobile devices for example J2SE, J2EE, J2ME
Versions are released with a JDK
Dev tools - NETBIN, JBUILDER, TEXTPAD

Application - standalone programs run on any machine with JVM
applets - run from web browser
Servlets- run from web server, creates dynamic web contents
Compiler - source  code to target language code as a single unit
Interpreter - individual step one at a time and executed immediately after translation
Magic is bytecode not executable file
Bytecode interpreted by JVM
So you write code for JVM ,NOT OS
JVM interprets and executes in a way that is compatible with current hardware architecture and OS
Features of java
1. Java is simple - As you will see gradually java is simple than any other OO languages. Pointers and multiple inheritance make programs more complicated . These are eliminated in java
2. Java is Distributed - Java is made to make distributed computing easy where more than one computers are involved.
3. Interpreted - Java interpreter translates the bytecode into machine languages of the target machine
4. Robust - Robust means reliable, Since java checks many possible errors might come during run time. That is java does not support pointers which eliminates the possibility of overwriting memory and corrupting data. Another thing is Exceptions which forces the programmer to use it. Hence java can detect the exceptions and respond it during run time, thereby making program execution normally.
5. Java is secure - Although java works under internet and networking environments , it implements different security mechanisms to protect the machine.
6. Architecture neutral - Since java is interpreted , it enables architecture neutral and since compilation is not made for any particular computer. Thereby we can say platform independent language.
7. Multithreaded - Different parts of the program can run under networking environment.
8. Java is portable - since java does not need to be recompiled again , since java compiler is written in java
9. One thing is that java is never faster than c++ since bytecode is interpreted and not directly executed by the system. This issue is handled by using JIT compiler for jvm.
10. Dynamic- New classes and interface can be added to it without recompilation.

Tuesday 02 August 2016 07:54:37 PM IST
======================================================
Identifiers - certain names given in programming languages
like variables, constants, methods , classes etc.
identifier consists of letters, digits, underscore, dollar. can not start with digit.
Numeric data types -
byte - 8-bit signed
short - 16 bit signed
int - 32 bit signed
long - 64 bit signed
float - 32 bit IEEE 754
double - 64 bit IEEE 754
  standard defines also SPECIAL FLOATING POINT values.
_____________________________________________________
public class FloatingNumber {

/** Author is S K Nayak
* @param args
*/
public static void main(String[] args) {
// TODO Auto
System.out.println("Hallo this is first program");
System.out.println(1.0 / 0);
System.out.println(-1.0 / 0);
System.out.println(0.0 / 0);
System.out.println(1.0 - 0.25);
System.out.println(1.0 - 0.9);
}

}
Infinity
-Infinity
NaN
0.75
0.09999999999999998
___________________________________________________
ARITHMETIC Operators
FLOATING POINT ARITHMETIC
Why answer is not more accurate ? double values are more accurate
Why it is called floating point?
c = ( 5.0 / 9 ) * (f - 32) gives actual result.
SHORT HAAND OPERATORS
CHARACTER DATA TYPES
Java uses 16 bit char representation represents any possible character in the world is UNICODE character which aslo includes ASCII characters. it is represented by \u0000 to \uFFFF.
INCREMENT OPERATORS
ESCAPE SEQUENCES
STRING TYPES

                      _____________X_____________

No comments:

Post a Comment

C Programming

  Table of Contents ​ About the Author 3 ​ Introduction 4 ​ Introduction to Computers 4 1. What is a Computer? 4 2. History...