SlideShare a Scribd company logo
Java  lab  lecture 1
With the invention of internet and world
wide web there is need of a language that
should be platform independent.
On internet we don't know in advance at
what platform our code or program
/application will be executed as all over the
world there are heterogeneous systems.
JAVA was not made for Internet
programming. Java was developed for
Microcontroller for platform neutral
execution. so there is no need to rewrite the
code each time for every Microcontroller.
James Gosling and his team start working on
a portable ,platform independent language
that could be used to produce code that
would run on variety of CPU under different
environment.
This effort leads to creation of JAVA
In portable language we can compile the
code by using different compiler on different
operating system.
e.g. in C source code
 On DOS we can compile the source code by
Turbo Borland Compiler
 On Window we can compile using VC++
Compiler
 For UNIX we can use CC/GCC compiler
JAVA VIRTUAL MACHINE is the
solution for platform independent
compilation
Specification designed by SUN Microsystems
1. Instruction set
2. File format
3. Class loading and execution Mechanism etc.
JVM is specification of JRE
JRE is implementation of JVM
JRE can be called JVM but JVM cannot be called JRE.
Car is called a Vehicle but Vehicle is not called Car
 A software vendor who wants to develop JRE
needs JVM
Main component of JRE
1 Byte code verifier
2.Class Loader
3.Just in time Compiler
4.Class Library
5.Security Policies
6.Memory Management.
 It is the package of JRE and tools(javac ,javap ,jar
etc.)
(jar is compression and decompression format of sun micro
system)
1. Application programmer needs JDK
2. End user needs JRE
3. A software vendor who wants to develop JRE
needs JVM(specification and license from
SunMicrosystem now owned by Oracle).
4. Every vendor can develop their own compiler of
java with license from sun micro system
according to their need.
The key to solve the security and portability
problem is that the output of Java compiler is not
executable code rather than it is BYTECODE.
Byte Code is a highly optimized set of
instructions to be executed by JRE(some time
called JVM)
JVM was designed as an interpreter for byte code.
JVM may be different from platform to platform
but all understand the same byte code.
 In real world we think in the form of object. We
give preference to object than on work that object
perform.
e.g: Teacher, Carpenter
JAVA designer want to develop a language that
should solve the problems that have solution
similar real world problems.
If we want to study we looks for teacher.
If we want to make a table, chair or any furniture we
looks for carpenter
 Object is an Instance of class
 At particular moment how that class is
behaving is know as object
 Suppose Light is class
Either it is on ,off,dim,bright
Light is on
Light is off
Light is bright
Light is Dim
Java  lab  lecture 1
Java  lab  lecture 1
 it is the way of thinking in terms of object on
the basis of this thinking a programming
model created by sun micro system in known
as object oriented programming structure
 SUN MicroSystem is a microelectronics
company designing chips for microcontroller
used in washing machines ,digital set top
box,Remote control etc.
 What is difference between microcontroller
and microprocessor?
Java's main features are
 1. Platform independent.
 2. Security
 For each platform we have to write a new
code.
 If a company is making 100 microcontroller
per day then 100 times we have to write the
code. because language depends on the
properties of hardware(instruction set,
instruction format, type of register)
Main Feature of Java:
1. Simple
2. Secure(The JVM performs verification on bytecode before running it to prevent the program
from performing unsafe operations such as branching to incorrect locations)
3. Object-Oriented
4. Robust(Java is robust because it is highly supported language, meaning that
unlike C you cannot crash your computer with a bad program)
5. Multithreaded
6. Architectural Neutral
(binary code format" that's independent of hardware
architectures, operating system interfaces, and window
systems)
7. Interpreted.
8. High-performance
(Just in time compilation)
9. Distributed (development of application to run over network
always need distributed languages)
10. Dynamic (During the execution of a program, Java can
dynamically load class libraries )
 It is slow in comparison of C/C++.because it
is both compiled and interpreted language.
 Applet cannot access local data. Only
download the data from site where applet is
located.
 No use of pointer so we cannot do flexible
data structure design.
 Need different JVM for different platform.
 It is strictly types language (every variable
have type, every expression has type) so
there is no flexibility in programming.
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
Java  lab  lecture 1
Java  lab  lecture 1
Java  lab  lecture 1
Java  lab  lecture 1
Java  lab  lecture 1
Java  lab  lecture 1
 1 Single Inheritance
 2 Multiple Inheritance
 3 Multilevel Inheritance
 4 Hierarchical Inheritance
 5 Hybrid Inheritance
 single inheritance is simply one subclass
extending one superclass. It is the simplest of
all.
 Multiple Inheritance is one class extending
multiple classes. As discussed before, Java
does not support multiple Inheritance.
However, with the help of interfaces, we can
visualize multiple Inheritance at work.
 A multilevel inheritance is about a superclass
extending its features to a subclass, which in
turns act as another superclass to a new
subclass. Multilevel inheritance is
implemented in a hierarchy. This means, once
a subclass, will be a future superclass.
 In hierarchical inheritance, one class acts as a
parent class for multiple subclasses.
 Hybrid inheritance is formed as a result of the
combination of both single and multiple
Inheritance. As multiple Inheritance is not
viable with classes, we achieve hybrid
inheritance through interfaces.
Java  lab  lecture 1
Java  lab  lecture 1
Java  lab  lecture 1
Java  lab  lecture 1
Java  lab  lecture 1
Class MyExample
{
public Static Void main(String arr[])
{
System.out.println(“this is my example”);
}
}
 The word Class means that a new class is defined.
 MyExample is an identifier(called class name)
 All members of class should be declared inside
curly braces {…………….}
 Execution always start from main method.
 The keyword public mean that member may be
accessed by code outside the class in which it is
declared.
 main() must be declared as public since it must be
called by the code outside of its class when the
program is started.
 Keyword static allow main() to be called without
having to instantiate a particular instance of class.
since main() is called by JVM before any object are
made.
 Keyword void tells the compiler that main()
does not return a value.
 Object of type String store character string in
this case arr is an command line argument
presents when program is executed.
 System is a predefined class that provides
access to the system and out is output
stream that is connected to console.
Execution Model of C and C++
1.Application file is read and format is checked.
2.If format is valid .its instruction is loaded.
3.Address of first Inst. Is loaded in PC
4.Process asked to start execution.
5.Address of Instruction fetched from PC one by one.
6.Instruction is fetched from memory and is executed.
2.Class file is read and its format is checked.
3,4.If format is valid, class loader is asked to load it.
5.Just in time compiler(JITC) is asked to execute the class.
6.Instruction of class is read one by one.
7.For each instruction security policy is checked and instruction is
executed only if it satisfy security policy.
 .
 Eclipse
Class Rectangle
{
int l,b
//attribute
public void display()
{
System.out.println(“Length=”+l);
System.out.println(“Breadth=”+b);
}
public int area()
{
Return l*b;
}
Public void setDimension(int x,int y)
{
I=x;
B=y;
}
}
Class RectangleTest
{
public static void main(String
arr[])
{
Rectangle r = new Rectangle();
r.setDimension(20,30)
{
System.out.println(“dimension of
rectangle are”);
r.display();
System.out.println(“area of
rectangle r is =”+r.area());
}}
 Classname refrencevariable = new classname();
 Reference variable is a implicit pointer which
is used to contain the reference of objects.
 In java reference variable are dynamically
created. Hence they don’t have name and are
referenced through their reference variables.
 In C++: there is static allocation of objects
 r
 Rectangle r ======== r
l
b
Java  lab  lecture 1
Java  lab  lecture 1

More Related Content

PPTX
Java ms harsha
Harsha Batra
 
DOCX
Java 3 rd sem. 2012 aug.ASSIGNMENT
mayank's it solution pvt.ltd
 
PDF
Java notes
Manish Swarnkar
 
PPT
Introduction to Java Programming, Basic Structure, variables Data type, input...
Mr. Akaash
 
DOC
Grade 8: Introduction To Java
nandanrocker
 
PDF
Java unit 1
Shipra Swati
 
PDF
Introduction to java technology
Indika Munaweera Kankanamge
 
PPTX
Introduction to java
Java Lover
 
Java ms harsha
Harsha Batra
 
Java 3 rd sem. 2012 aug.ASSIGNMENT
mayank's it solution pvt.ltd
 
Java notes
Manish Swarnkar
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Mr. Akaash
 
Grade 8: Introduction To Java
nandanrocker
 
Java unit 1
Shipra Swati
 
Introduction to java technology
Indika Munaweera Kankanamge
 
Introduction to java
Java Lover
 

What's hot (19)

DOCX
Introduction to java
jayc8586
 
PDF
Chapter 1. java programming language overview
Jong Soon Bok
 
PDF
Introduction to Java Programming Language
jaimefrozr
 
PPT
Byte code jvm
myrajendra
 
PDF
JAVA Program Examples
Prof Chethan Raj C
 
PPTX
Training on java niit (sahil gupta 9068557926)
Sahil Gupta
 
PPT
1 Introduction To Java Technology
dM Technologies
 
PPTX
Presentation on Core java
mahir jain
 
PPT
CS Lesson: Introduction to the Java virtual Machine
Katrin Becker
 
PPT
Core Java
christ university
 
PPTX
Java architecture
Rakesh
 
PDF
What is-java
Shahid Rasheed
 
PPT
Core java slides
Abhilash Nair
 
PPTX
Introduction to java
Sandeep Rawat
 
PPTX
Java introduction
NAVEENA ESWARAN
 
PPTX
Programming in Java
Abhilash Nair
 
PPTX
Introduction to Java Programming
Saravanakumar R
 
Introduction to java
jayc8586
 
Chapter 1. java programming language overview
Jong Soon Bok
 
Introduction to Java Programming Language
jaimefrozr
 
Byte code jvm
myrajendra
 
JAVA Program Examples
Prof Chethan Raj C
 
Training on java niit (sahil gupta 9068557926)
Sahil Gupta
 
1 Introduction To Java Technology
dM Technologies
 
Presentation on Core java
mahir jain
 
CS Lesson: Introduction to the Java virtual Machine
Katrin Becker
 
Java architecture
Rakesh
 
What is-java
Shahid Rasheed
 
Core java slides
Abhilash Nair
 
Introduction to java
Sandeep Rawat
 
Java introduction
NAVEENA ESWARAN
 
Programming in Java
Abhilash Nair
 
Introduction to Java Programming
Saravanakumar R
 
Ad

Similar to Java lab lecture 1 (20)

PPTX
Java lab zero lecture
vishal choudhary
 
PDF
JAVA for Every one
Satyam Pandey
 
DOCX
JAVA Programming-Lectures-1_javaFeatures (2).docx
sonalipatil225940
 
PDF
OOPS JAVA.pdf
DeepanshuMidha5140
 
PPTX
Presentación rs232 java
John Rojas
 
PPTX
Lecture java variable , data type, token
ChandrashekharSingh859453
 
PPTX
Java Lecture 1
Qualys
 
PDF
Sybsc cs sem 3 core java
WE-IT TUTORIALS
 
PDF
Javanotes ww8
kumar467
 
PPTX
What is Java, JDK, JVM, Introduction to Java.pptx
kumarsuneel3997
 
PDF
Introduction to Java Programming.pdf
AdiseshaK
 
PPTX
Unit1 JAVA.pptx
RahulAnand111531
 
PPTX
2 22CA026_Advance Java Programming_Data types and Operators.pptx
dolphiverma80
 
PDF
Java Programming
Prof. Dr. K. Adisesha
 
PPTX
Iintroduction to java , Java Coding , basics of java.pptx
MayankParashar31
 
PPT
Java2020 programming basics and fundamentals
swecsaleem
 
PDF
Java chapter 1
Mukesh Tekwani
 
PDF
0f0cef_1dac552af56c4338ab0672859199e693.pdf
DeepakChaudhriAmbali
 
Java lab zero lecture
vishal choudhary
 
JAVA for Every one
Satyam Pandey
 
JAVA Programming-Lectures-1_javaFeatures (2).docx
sonalipatil225940
 
OOPS JAVA.pdf
DeepanshuMidha5140
 
Presentación rs232 java
John Rojas
 
Lecture java variable , data type, token
ChandrashekharSingh859453
 
Java Lecture 1
Qualys
 
Sybsc cs sem 3 core java
WE-IT TUTORIALS
 
Javanotes ww8
kumar467
 
What is Java, JDK, JVM, Introduction to Java.pptx
kumarsuneel3997
 
Introduction to Java Programming.pdf
AdiseshaK
 
Unit1 JAVA.pptx
RahulAnand111531
 
2 22CA026_Advance Java Programming_Data types and Operators.pptx
dolphiverma80
 
Java Programming
Prof. Dr. K. Adisesha
 
Iintroduction to java , Java Coding , basics of java.pptx
MayankParashar31
 
Java2020 programming basics and fundamentals
swecsaleem
 
Java chapter 1
Mukesh Tekwani
 
0f0cef_1dac552af56c4338ab0672859199e693.pdf
DeepakChaudhriAmbali
 
Ad

More from vishal choudhary (20)

PPTX
mobile application using automatin using node ja java on
vishal choudhary
 
PPTX
mobile development using node js and java
vishal choudhary
 
PPTX
Pixel to Percentage conversion Convert left and right padding of a div to per...
vishal choudhary
 
PPTX
esponsive web design means that your website (
vishal choudhary
 
PPTX
function in php using like three type of function
vishal choudhary
 
PPTX
data base connectivity in php using msql database
vishal choudhary
 
PPTX
software evelopment life cycle model and example of water fall model
vishal choudhary
 
PPTX
software Engineering lecture on development life cycle
vishal choudhary
 
PPTX
strings in php how to use different data types in string
vishal choudhary
 
PPTX
OPEN SOURCE WEB APPLICATION DEVELOPMENT question
vishal choudhary
 
PPTX
web performnace optimization using css minification
vishal choudhary
 
PPTX
web performance optimization using style
vishal choudhary
 
PPTX
Data types and variables in php for writing and databse
vishal choudhary
 
PPTX
Data types and variables in php for writing
vishal choudhary
 
PPTX
Data types and variables in php for writing
vishal choudhary
 
PPTX
sofwtare standard for test plan it execution
vishal choudhary
 
PPTX
Software test policy and test plan in development
vishal choudhary
 
PPTX
function in php like control loop and its uses
vishal choudhary
 
PPTX
introduction to php and its uses in daily
vishal choudhary
 
PPTX
data type in php and its introduction to use
vishal choudhary
 
mobile application using automatin using node ja java on
vishal choudhary
 
mobile development using node js and java
vishal choudhary
 
Pixel to Percentage conversion Convert left and right padding of a div to per...
vishal choudhary
 
esponsive web design means that your website (
vishal choudhary
 
function in php using like three type of function
vishal choudhary
 
data base connectivity in php using msql database
vishal choudhary
 
software evelopment life cycle model and example of water fall model
vishal choudhary
 
software Engineering lecture on development life cycle
vishal choudhary
 
strings in php how to use different data types in string
vishal choudhary
 
OPEN SOURCE WEB APPLICATION DEVELOPMENT question
vishal choudhary
 
web performnace optimization using css minification
vishal choudhary
 
web performance optimization using style
vishal choudhary
 
Data types and variables in php for writing and databse
vishal choudhary
 
Data types and variables in php for writing
vishal choudhary
 
Data types and variables in php for writing
vishal choudhary
 
sofwtare standard for test plan it execution
vishal choudhary
 
Software test policy and test plan in development
vishal choudhary
 
function in php like control loop and its uses
vishal choudhary
 
introduction to php and its uses in daily
vishal choudhary
 
data type in php and its introduction to use
vishal choudhary
 

Recently uploaded (20)

PDF
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
DOCX
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
PPTX
Congenital Hypothyroidism pptx
AneetaSharma15
 
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
PPTX
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
RAKESH SAJJAN
 
PDF
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
PDF
Landforms and landscapes data surprise preview
jpinnuck
 
PPTX
Strengthening open access through collaboration: building connections with OP...
Jisc
 
PPTX
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
PPTX
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
PPTX
Care of patients with elImination deviation.pptx
AneetaSharma15
 
DOCX
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
PPTX
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
PDF
3.The-Rise-of-the-Marathas.pdfppt/pdf/8th class social science Exploring Soci...
Sandeep Swamy
 
PDF
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
PPTX
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 
PDF
Sunset Boulevard Student Revision Booklet
jpinnuck
 
PPTX
vedic maths in python:unleasing ancient wisdom with modern code
mistrymuskan14
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
Congenital Hypothyroidism pptx
AneetaSharma15
 
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
RAKESH SAJJAN
 
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
Landforms and landscapes data surprise preview
jpinnuck
 
Strengthening open access through collaboration: building connections with OP...
Jisc
 
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
Care of patients with elImination deviation.pptx
AneetaSharma15
 
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
3.The-Rise-of-the-Marathas.pdfppt/pdf/8th class social science Exploring Soci...
Sandeep Swamy
 
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 
Sunset Boulevard Student Revision Booklet
jpinnuck
 
vedic maths in python:unleasing ancient wisdom with modern code
mistrymuskan14
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 

Java lab lecture 1

  • 2. With the invention of internet and world wide web there is need of a language that should be platform independent. On internet we don't know in advance at what platform our code or program /application will be executed as all over the world there are heterogeneous systems.
  • 3. JAVA was not made for Internet programming. Java was developed for Microcontroller for platform neutral execution. so there is no need to rewrite the code each time for every Microcontroller.
  • 4. James Gosling and his team start working on a portable ,platform independent language that could be used to produce code that would run on variety of CPU under different environment. This effort leads to creation of JAVA
  • 5. In portable language we can compile the code by using different compiler on different operating system. e.g. in C source code  On DOS we can compile the source code by Turbo Borland Compiler  On Window we can compile using VC++ Compiler  For UNIX we can use CC/GCC compiler
  • 6. JAVA VIRTUAL MACHINE is the solution for platform independent compilation
  • 7. Specification designed by SUN Microsystems 1. Instruction set 2. File format 3. Class loading and execution Mechanism etc. JVM is specification of JRE JRE is implementation of JVM JRE can be called JVM but JVM cannot be called JRE. Car is called a Vehicle but Vehicle is not called Car
  • 8.  A software vendor who wants to develop JRE needs JVM Main component of JRE 1 Byte code verifier 2.Class Loader 3.Just in time Compiler 4.Class Library 5.Security Policies 6.Memory Management.
  • 9.  It is the package of JRE and tools(javac ,javap ,jar etc.) (jar is compression and decompression format of sun micro system) 1. Application programmer needs JDK 2. End user needs JRE 3. A software vendor who wants to develop JRE needs JVM(specification and license from SunMicrosystem now owned by Oracle). 4. Every vendor can develop their own compiler of java with license from sun micro system according to their need.
  • 10. The key to solve the security and portability problem is that the output of Java compiler is not executable code rather than it is BYTECODE. Byte Code is a highly optimized set of instructions to be executed by JRE(some time called JVM) JVM was designed as an interpreter for byte code. JVM may be different from platform to platform but all understand the same byte code.
  • 11.  In real world we think in the form of object. We give preference to object than on work that object perform. e.g: Teacher, Carpenter JAVA designer want to develop a language that should solve the problems that have solution similar real world problems. If we want to study we looks for teacher. If we want to make a table, chair or any furniture we looks for carpenter
  • 12.  Object is an Instance of class  At particular moment how that class is behaving is know as object  Suppose Light is class Either it is on ,off,dim,bright Light is on Light is off Light is bright Light is Dim
  • 15.  it is the way of thinking in terms of object on the basis of this thinking a programming model created by sun micro system in known as object oriented programming structure  SUN MicroSystem is a microelectronics company designing chips for microcontroller used in washing machines ,digital set top box,Remote control etc.  What is difference between microcontroller and microprocessor?
  • 16. Java's main features are  1. Platform independent.  2. Security
  • 17.  For each platform we have to write a new code.  If a company is making 100 microcontroller per day then 100 times we have to write the code. because language depends on the properties of hardware(instruction set, instruction format, type of register)
  • 18. Main Feature of Java: 1. Simple 2. Secure(The JVM performs verification on bytecode before running it to prevent the program from performing unsafe operations such as branching to incorrect locations) 3. Object-Oriented 4. Robust(Java is robust because it is highly supported language, meaning that unlike C you cannot crash your computer with a bad program) 5. Multithreaded 6. Architectural Neutral (binary code format" that's independent of hardware architectures, operating system interfaces, and window systems) 7. Interpreted. 8. High-performance (Just in time compilation) 9. Distributed (development of application to run over network always need distributed languages) 10. Dynamic (During the execution of a program, Java can dynamically load class libraries )
  • 19.  It is slow in comparison of C/C++.because it is both compiled and interpreted language.  Applet cannot access local data. Only download the data from site where applet is located.  No use of pointer so we cannot do flexible data structure design.  Need different JVM for different platform.  It is strictly types language (every variable have type, every expression has type) so there is no flexibility in programming.
  • 20. 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
  • 27.  1 Single Inheritance  2 Multiple Inheritance  3 Multilevel Inheritance  4 Hierarchical Inheritance  5 Hybrid Inheritance
  • 28.  single inheritance is simply one subclass extending one superclass. It is the simplest of all.
  • 29.  Multiple Inheritance is one class extending multiple classes. As discussed before, Java does not support multiple Inheritance. However, with the help of interfaces, we can visualize multiple Inheritance at work.
  • 30.  A multilevel inheritance is about a superclass extending its features to a subclass, which in turns act as another superclass to a new subclass. Multilevel inheritance is implemented in a hierarchy. This means, once a subclass, will be a future superclass.
  • 31.  In hierarchical inheritance, one class acts as a parent class for multiple subclasses.
  • 32.  Hybrid inheritance is formed as a result of the combination of both single and multiple Inheritance. As multiple Inheritance is not viable with classes, we achieve hybrid inheritance through interfaces.
  • 38. Class MyExample { public Static Void main(String arr[]) { System.out.println(“this is my example”); } }
  • 39.  The word Class means that a new class is defined.  MyExample is an identifier(called class name)  All members of class should be declared inside curly braces {…………….}  Execution always start from main method.  The keyword public mean that member may be accessed by code outside the class in which it is declared.  main() must be declared as public since it must be called by the code outside of its class when the program is started.  Keyword static allow main() to be called without having to instantiate a particular instance of class. since main() is called by JVM before any object are made.
  • 40.  Keyword void tells the compiler that main() does not return a value.  Object of type String store character string in this case arr is an command line argument presents when program is executed.  System is a predefined class that provides access to the system and out is output stream that is connected to console.
  • 41. Execution Model of C and C++ 1.Application file is read and format is checked. 2.If format is valid .its instruction is loaded. 3.Address of first Inst. Is loaded in PC 4.Process asked to start execution. 5.Address of Instruction fetched from PC one by one. 6.Instruction is fetched from memory and is executed.
  • 42. 2.Class file is read and its format is checked. 3,4.If format is valid, class loader is asked to load it. 5.Just in time compiler(JITC) is asked to execute the class. 6.Instruction of class is read one by one. 7.For each instruction security policy is checked and instruction is executed only if it satisfy security policy.
  • 44. Class Rectangle { int l,b //attribute public void display() { System.out.println(“Length=”+l); System.out.println(“Breadth=”+b); } public int area() { Return l*b; } Public void setDimension(int x,int y) { I=x; B=y; } } Class RectangleTest { public static void main(String arr[]) { Rectangle r = new Rectangle(); r.setDimension(20,30) { System.out.println(“dimension of rectangle are”); r.display(); System.out.println(“area of rectangle r is =”+r.area()); }}
  • 45.  Classname refrencevariable = new classname();  Reference variable is a implicit pointer which is used to contain the reference of objects.  In java reference variable are dynamically created. Hence they don’t have name and are referenced through their reference variables.  In C++: there is static allocation of objects  r  Rectangle r ======== r l b