Byte Code: To solve the security and portability problem is that output of java compiler is
not executable code but a byte code.
Byte code is a highly optimized set of instruction designed to be executed by the java run time
system (JRE) which is called JVM
 A simple Java Program: to print a string “welcome to java”
Class Welcome
{
Public static void main (String arr[])
{
System.out.println (“Welcomes to Java”);
}}
 Explanation:
a) The word class means we declared a new class with name Welcome
b) All the class members declared in opening and closing braces ({………..}.
c) All java applications begin their execution from main().
d) Main () is declared public because it is accessed outside the class by JVM.
e) Static allow main() to be accessed without declaring any object of class by JVM.
f) Keyword void() simply tells the compiler that main() does not return a value.
g) String store character string in arr[] if input is received by command line argument during
execution time.
h) System is predefined class that provides access to systemand out is output stream that is
connected to console (I/O).
 The main feature (advantages of Java) of Java:
a. Simple: if you have experience with C/C++ language then programming in java is not a
difficult task
b. Object oriented language: java is purely object oriented language so developing the large
java applications is easy, easy for reusability as well to debug the program.
c. Robust: a language is robust if it executes and gives the same result of program on different
platform in different environment. and run error free after compiling and running at once
.what you written in code and what you expect the result is same on different hardware and
O/S.
d. Multithreaded: multithreading programming allows you to write program that do many
things simultaneously. it means same program execute different function at same time.
e. Architectural Neutral: Changing the hardware and operating systemof computer system
have no effect on Java program.
f. Interpreted: it is an interpreted language Byte code is compiled line by line by JRE.
g. Distributed: Java is designed for distributed environment of internet can handle TCP/IP
protocols.
h. Dynamic: in java there is variety of information that is used to be verified and resolve the
access to objects at run time this makes it possible to dynamically link the code in a safe
manner.
 Limitation of Java:
a. It is slow in comparison of C/C++.because it is both compiled and interpreted language.
b. Applet cannot access local data. Only download the data from site where applet is
located.
c. No use of pointer so we cannot do flexible data structure design.
d. Need different JVM for different platform.
e. It is strictly types language (every variable have type, every expression has type) so
there is no flexibility in programming.
 Difference betweenC ++ and Java
S.No JAVA C++
1 Java is completely object oriented
language
C++ is extension of C with object oriented
behavior
2 Java does not support multiple
inheritances. But it can be achieved
using interface if needed.
C++ support multiple inheritance
3 Java does not support global variable Global variable can be declared in C++
4 Java does not support pointer. C++ support pointers.
5 In Java there is no destructor. In C++ there is use of destructor
6 Java does not provide header file C++ has header file.
7 Java code run on Virtual machine
(JVM)
C++ code runs on actual machine
8 In java automatic memory
management and garbage collection
Memory management is done manually by
new/delete.
9 Write once run any where Write once compile anywhere

Lecture19.07.2014

  • 1.
    Byte Code: Tosolve the security and portability problem is that output of java compiler is not executable code but a byte code. Byte code is a highly optimized set of instruction designed to be executed by the java run time system (JRE) which is called JVM  A simple Java Program: to print a string “welcome to java” Class Welcome { Public static void main (String arr[]) { System.out.println (“Welcomes to Java”); }}  Explanation: a) The word class means we declared a new class with name Welcome b) All the class members declared in opening and closing braces ({………..}. c) All java applications begin their execution from main(). d) Main () is declared public because it is accessed outside the class by JVM. e) Static allow main() to be accessed without declaring any object of class by JVM. f) Keyword void() simply tells the compiler that main() does not return a value. g) String store character string in arr[] if input is received by command line argument during execution time. h) System is predefined class that provides access to systemand out is output stream that is connected to console (I/O).  The main feature (advantages of Java) of Java: a. Simple: if you have experience with C/C++ language then programming in java is not a difficult task b. Object oriented language: java is purely object oriented language so developing the large java applications is easy, easy for reusability as well to debug the program. c. Robust: a language is robust if it executes and gives the same result of program on different platform in different environment. and run error free after compiling and running at once .what you written in code and what you expect the result is same on different hardware and O/S.
  • 2.
    d. Multithreaded: multithreadingprogramming allows you to write program that do many things simultaneously. it means same program execute different function at same time. e. Architectural Neutral: Changing the hardware and operating systemof computer system have no effect on Java program. f. Interpreted: it is an interpreted language Byte code is compiled line by line by JRE. g. Distributed: Java is designed for distributed environment of internet can handle TCP/IP protocols. h. Dynamic: in java there is variety of information that is used to be verified and resolve the access to objects at run time this makes it possible to dynamically link the code in a safe manner.  Limitation of Java: a. It is slow in comparison of C/C++.because it is both compiled and interpreted language. b. Applet cannot access local data. Only download the data from site where applet is located. c. No use of pointer so we cannot do flexible data structure design. d. Need different JVM for different platform. e. It is strictly types language (every variable have type, every expression has type) so there is no flexibility in programming.  Difference betweenC ++ and Java S.No JAVA C++ 1 Java is completely object oriented language C++ is extension of C with object oriented behavior 2 Java does not support multiple inheritances. But it can be achieved using interface if needed. C++ support multiple inheritance 3 Java does not support global variable Global variable can be declared in C++ 4 Java does not support pointer. C++ support pointers. 5 In Java there is no destructor. In C++ there is use of destructor 6 Java does not provide header file C++ has header file. 7 Java code run on Virtual machine (JVM) C++ code runs on actual machine 8 In java automatic memory management and garbage collection Memory management is done manually by new/delete. 9 Write once run any where Write once compile anywhere