SlideShare una empresa de Scribd logo
1 de 19
How is Java different from other languages
• Less than you think:
– Java is an imperative language (like C++, Ada, C, Pascal)
– Java is interpreted (like LISP, APL)
– Java is garbage-collected (like LISP, Eiffel, Modula-3)
– Java can be compiled (like LISP)
– Java is object-oriented (like C++, Ada, Eiffel)
• A succesful hybrid for a specific-application domain
• A reasonable general-purpose language for non-real-
time applications
• Work in progress: language evolving rapidly
Original design goals (white paper 1993)
• Simple
• Object-oriented (inheritance, polymorphism)
• Distributed
• Interpreted
• multithreaded
• Robust
• Secure
• Architecture-neutral
• a language with threads, objects, exceptions and
garbage-collection can’t really be simple!
Portability
• Critical concern: write once-run everywhere
• Consequences:
– Portable interpreter
– definition through virtual machine: the JVM
– run-time representation has high-level semantics
– supports dynamic loading
– (+) high-level representation can be queried at run-time to
provide reflection
– (-) Dynamic features make it hard to fully compile, safety
requires numerous run-time checks
Contrast with conventional systems languages
(C, C++, Ada)
• Conventional languages are fully compiled:
– run-time structure is machine language
– minimal run-time type information
– language provides low-level tools for accessing storage
– safety requires fewer run-time checks because compiler
– (least for Ada and somewhat for C++) can verify correctness
statically.
– Languages require static binding, run-time image cannot be
easily modified
– Different compilers may create portability problems
Serious omissions
• No parameterized classes (C++ templates, Ada
generics)
• Can simulate generic programming with untyped
style: casting Object down into specific class.
– Forces code duplication, or run-time conversions
• No operator overloading (syntactic annoyance)
• No enumerations (using final constants is clumsy)
A new construct: interfaces
• Allow otherwise unrelated classes to satisfy a given
requirement
• Orthogonal to inheritance
– inheritance: an A is-a B (has the attributes of a B,
and possibly others)
– interface: an A can-do X (and other unrelated
actions)
– better model for multiple inheritance
• More costly at run-time (minor consideration)
Interface Comparable
public interface Comparable {
public int CompareTo (Object x) throws
ClassCastException;
// returns -1 if this < x,
// 0 if this = x,
// 1 if this > x
};
// Implementation has to cast x to the proper class.
// Any class that may appear in a container should implement
Comparable
Threads and their interface
class Doodler extends Thread {
// override the basic method of a thread
public void run( ) {
... // scribble something
}
} …
Doodler gary = new Doodler ( );
gary.start( ); // calls the run method
The runnable interface allows any object to
have dynamic behavior
class Simple_Gizmo { …}
class Active_Gizmo extends Simple_Gizmo implements
Runnable {
public void run ( ) {…}
}
// a thread can be constructed from anything that runs:
Thread thing1 = new Thread (new Active_Gizmo ( ));
Thread thing2 = new Thread (new Active_Gizmo ( ));
thing1.start( ); thing2.start ( );
Interfaces and event-driven programming
• A high-level model of event-handling:
– graphic objects generate events
• mouse click, menu selection, window close...
– an object can be designated as a handler
• a listener, in Java terminology
– an event can be broadcast to several handlers
• several listeners can be attached to a source of events
– a handler must implement an interface
• actionPerformed, keyPressed, mouseExited..
Built-in interfaces for event handlers
public interface MouseListener
{
void mousePressed (MouseEvent event);
void mouseREleased (MouseEvent event);
void mouseClicked (Mouseevent event);
void mouseEntered (Mouseevent event);
void mouseExited (MouseEvent event);
}
Typically, handler only needs to process a few of the above, and
supply dummy methods for the others
Adapters: a coding convenience
class mouseAdapter implements mouseListener
{
public void mousePressed (MouseEvent event) { } ;
public void mouseREleased (MouseEvent event) { };
public void mouseClicked (Mouseevent event) { };
public void mouseEntered (Mouseevent event) { };
public void mouseExited (MouseEvent event) { };
};
class MouseClickListener extends Mouseadapter {
public void mouseClicked (MouseEvent event {…};
// only the method of interest needs to be supplied
}
Events and listeners
class Calm_Down extends Jframe {
private Jbutton help := new Jbutton (“HELP!!!”);
// indicate that the current frame handles button clicks
help.addActionListener (this);
// if the button is clicked the frame executes the following:
public void actionPerformed (ActionEvent e) {
if (e.getSource () == help) {
System.out.println
(“can’t be that bad. What’s the problem?”);
}
}
}
Event handlers and nested classes
• Inner classes make it possible to add local handlers to any
component
class reactive_panel extends Jpanel { // a swing component
JButton b1;
Public reactive_panel (Container c) {
b1 = new JButton (“flash”);
add (b1);
MyListener ml = new Mylistener ( ) ;
b1.addActionListener (ml);
private class MyListener implements ActionListener {
public void actionPerformed (ActionEvent e) { …}
}
Introspection, reflection, and typeless
programming
public void DoSomething (Object thing) {
// what can be do with a generic object?
if (thing instanceof gizmo) {
// we know the methods in class Gizmo
….
• Instanceof requires an accessible run-time descriptor in the
object.
• Reflection is a general programming model that relies on run-
time representations of aspects of the computation that are
usually not available to the programmer.
• More common in Smalltalk and LISP.
Reflection and metaprogramming
• Given an object at run-time, it is possible to obtain:
– its class
– its fields (data members) as strings
– the classes of its fields
– the methods of its class, as strings
– the types of the methods
• It is then possible to construct calls to these methods
• This is possible because the JVM provides a high-
level representation of a class, with embedded
strings that allow almost complete disassembly.
Reflection classes
• java.lang.Class
– Class.getMethods () returns array of method objects
– Class.getConstructor (Class[ ] parameterTypes)
• returns the constructor with those parameters
• java.lang.reflect.Array
– Array.NewInstance (Class componentType, int length)
• java.lang.reflect.Field
• java.lang.reflect.Method
• All of the above require the existence of run-time
objects that describe methods and classes
Reflection and Beans
• The beans technology requires run-time examination
of foreign objects, in order to build dynamically a
usable interface for them.
• Class Introspector builds a method dictionary based
on simple naming conventions:
public boolean isCoffeeBean ( ); // is... predicate
public int getRoast ( ); // get... retrieval
public void setRoast (int darkness) ; // set… assignment
An endless supply of libraries
• The power of the language is in the large set of
libraries in existence. The language is successful if
programmers find libraries confortable:
• JFC and the Swing package
• Pluggable look and Feel
• Graphics
• Files and Streams
• Networking
• Enterprise libraries: CORBA, RMI, Serialization,
JDBC

Más contenido relacionado

La actualidad más candente

20160520 what youneedtoknowaboutlambdas
20160520 what youneedtoknowaboutlambdas20160520 what youneedtoknowaboutlambdas
20160520 what youneedtoknowaboutlambdasshinolajla
 
Scala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud FoundryScala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud FoundryPray Desai
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)arvind pandey
 
2CPP04 - Objects and Classes
2CPP04 - Objects and Classes2CPP04 - Objects and Classes
2CPP04 - Objects and ClassesMichael Heron
 
Scala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationScala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationMartin Odersky
 
Clojure - An Introduction for Lisp Programmers
Clojure - An Introduction for Lisp ProgrammersClojure - An Introduction for Lisp Programmers
Clojure - An Introduction for Lisp Programmerselliando dias
 
Practical type mining in Scala
Practical type mining in ScalaPractical type mining in Scala
Practical type mining in ScalaRose Toomey
 
Functional Programming In Practice
Functional Programming In PracticeFunctional Programming In Practice
Functional Programming In PracticeMichiel Borkent
 
flatMap Oslo presentation slides
flatMap Oslo presentation slidesflatMap Oslo presentation slides
flatMap Oslo presentation slidesMartin Odersky
 
Clojure talk at Münster JUG
Clojure talk at Münster JUGClojure talk at Münster JUG
Clojure talk at Münster JUGAlex Ott
 
Implementing Higher-Kinded Types in Dotty
Implementing Higher-Kinded Types in DottyImplementing Higher-Kinded Types in Dotty
Implementing Higher-Kinded Types in DottyMartin Odersky
 

La actualidad más candente (17)

From DOT to Dotty
From DOT to DottyFrom DOT to Dotty
From DOT to Dotty
 
20160520 what youneedtoknowaboutlambdas
20160520 what youneedtoknowaboutlambdas20160520 what youneedtoknowaboutlambdas
20160520 what youneedtoknowaboutlambdas
 
Scala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud FoundryScala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud Foundry
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
 
Scala Intro
Scala IntroScala Intro
Scala Intro
 
2CPP04 - Objects and Classes
2CPP04 - Objects and Classes2CPP04 - Objects and Classes
2CPP04 - Objects and Classes
 
Scala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationScala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentation
 
Clojure - An Introduction for Lisp Programmers
Clojure - An Introduction for Lisp ProgrammersClojure - An Introduction for Lisp Programmers
Clojure - An Introduction for Lisp Programmers
 
Scala basic
Scala basicScala basic
Scala basic
 
Practical type mining in Scala
Practical type mining in ScalaPractical type mining in Scala
Practical type mining in Scala
 
Core java
Core javaCore java
Core java
 
Functional Programming In Practice
Functional Programming In PracticeFunctional Programming In Practice
Functional Programming In Practice
 
flatMap Oslo presentation slides
flatMap Oslo presentation slidesflatMap Oslo presentation slides
flatMap Oslo presentation slides
 
Clojure talk at Münster JUG
Clojure talk at Münster JUGClojure talk at Münster JUG
Clojure talk at Münster JUG
 
C++ overview
C++ overviewC++ overview
C++ overview
 
Implementing Higher-Kinded Types in Dotty
Implementing Higher-Kinded Types in DottyImplementing Higher-Kinded Types in Dotty
Implementing Higher-Kinded Types in Dotty
 
camel-scala.pdf
camel-scala.pdfcamel-scala.pdf
camel-scala.pdf
 

Destacado

Recurso electronico, virus y antivirus
Recurso electronico, virus y antivirusRecurso electronico, virus y antivirus
Recurso electronico, virus y antivirusMajo1324
 
300.49 usage, security and maintenance of the gso cellular telephone
300.49 usage, security and maintenance of the gso cellular telephone300.49 usage, security and maintenance of the gso cellular telephone
300.49 usage, security and maintenance of the gso cellular telephoneNo Kill Shelter Alliance
 
Rubrica pid julian
Rubrica pid   julianRubrica pid   julian
Rubrica pid julianJulian Paez
 
Application Paper - Digital Universe
Application Paper - Digital UniverseApplication Paper - Digital Universe
Application Paper - Digital UniverseFatema Tuz Zohra
 
Dependency Finder Tutorial
Dependency Finder TutorialDependency Finder Tutorial
Dependency Finder TutorialJean Tessier
 
대신리포트_모닝미팅_140624
대신리포트_모닝미팅_140624대신리포트_모닝미팅_140624
대신리포트_모닝미팅_140624DaishinSecurities
 
Emergencia salud 1
Emergencia salud 1Emergencia salud 1
Emergencia salud 1JANXHITO
 
Plantilla presentaciones educa digital regional 2014...
Plantilla presentaciones educa digital regional 2014...Plantilla presentaciones educa digital regional 2014...
Plantilla presentaciones educa digital regional 2014...claullini
 
Cuidados com os dentes 1
Cuidados com os dentes 1Cuidados com os dentes 1
Cuidados com os dentes 1Barbaraqsms
 

Destacado (20)

Recurso electronico, virus y antivirus
Recurso electronico, virus y antivirusRecurso electronico, virus y antivirus
Recurso electronico, virus y antivirus
 
300.49 usage, security and maintenance of the gso cellular telephone
300.49 usage, security and maintenance of the gso cellular telephone300.49 usage, security and maintenance of the gso cellular telephone
300.49 usage, security and maintenance of the gso cellular telephone
 
Donde estan mis valores 10 1
Donde estan mis valores 10 1Donde estan mis valores 10 1
Donde estan mis valores 10 1
 
Rubrica pid julian
Rubrica pid   julianRubrica pid   julian
Rubrica pid julian
 
Multiboot
MultibootMultiboot
Multiboot
 
Orange
OrangeOrange
Orange
 
Application Paper - Digital Universe
Application Paper - Digital UniverseApplication Paper - Digital Universe
Application Paper - Digital Universe
 
Tic
TicTic
Tic
 
Drivermax driud 9
Drivermax driud 9Drivermax driud 9
Drivermax driud 9
 
Magtertexto
MagtertextoMagtertexto
Magtertexto
 
Dependency Finder Tutorial
Dependency Finder TutorialDependency Finder Tutorial
Dependency Finder Tutorial
 
Pert -cpm
Pert  -cpmPert  -cpm
Pert -cpm
 
Rap pres susan pintar
Rap pres susan pintarRap pres susan pintar
Rap pres susan pintar
 
대신리포트_모닝미팅_140624
대신리포트_모닝미팅_140624대신리포트_모닝미팅_140624
대신리포트_모닝미팅_140624
 
Panóptico desejo
Panóptico desejoPanóptico desejo
Panóptico desejo
 
Emergencia salud 1
Emergencia salud 1Emergencia salud 1
Emergencia salud 1
 
Каталог LR 2013
Каталог LR 2013Каталог LR 2013
Каталог LR 2013
 
Plantilla presentaciones educa digital regional 2014...
Plantilla presentaciones educa digital regional 2014...Plantilla presentaciones educa digital regional 2014...
Plantilla presentaciones educa digital regional 2014...
 
Solá y suspensión de la ley cerrojo
Solá y suspensión de la ley cerrojoSolá y suspensión de la ley cerrojo
Solá y suspensión de la ley cerrojo
 
Cuidados com os dentes 1
Cuidados com os dentes 1Cuidados com os dentes 1
Cuidados com os dentes 1
 

Similar a Basic info on java intro

Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptxVijalJain3
 
Short intro to scala and the play framework
Short intro to scala and the play frameworkShort intro to scala and the play framework
Short intro to scala and the play frameworkFelipe
 
Aggregate Programming in Scala
Aggregate Programming in ScalaAggregate Programming in Scala
Aggregate Programming in ScalaRoberto Casadei
 
Functional Programming In Jdk8
Functional Programming In Jdk8 Functional Programming In Jdk8
Functional Programming In Jdk8 Bansilal Haudakari
 
Beginning Java for .NET developers
Beginning Java for .NET developersBeginning Java for .NET developers
Beginning Java for .NET developersAndrei Rinea
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT studentsPartnered Health
 
Jslab rssh: JS as language platform
Jslab rssh:  JS as language platformJslab rssh:  JS as language platform
Jslab rssh: JS as language platformRuslan Shevchenko
 
JSLab.Руслан Шевченко."JavaScript как платформа компиляции"
JSLab.Руслан Шевченко."JavaScript как платформа компиляции"JSLab.Руслан Шевченко."JavaScript как платформа компиляции"
JSLab.Руслан Шевченко."JavaScript как платформа компиляции"GeeksLab Odessa
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Nayden Gochev
 
Developer’s viewpoint on swift programming language
Developer’s viewpoint on swift programming languageDeveloper’s viewpoint on swift programming language
Developer’s viewpoint on swift programming languageAzilen Technologies Pvt. Ltd.
 
Multi-threading in the modern era: Vertx Akka and Quasar
Multi-threading in the modern era: Vertx Akka and QuasarMulti-threading in the modern era: Vertx Akka and Quasar
Multi-threading in the modern era: Vertx Akka and QuasarGal Marder
 
Vk.amberfog.com gtug part1_introduction2_javaandroid_gtug
Vk.amberfog.com gtug part1_introduction2_javaandroid_gtugVk.amberfog.com gtug part1_introduction2_javaandroid_gtug
Vk.amberfog.com gtug part1_introduction2_javaandroid_gtugketan_patel25
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdfHiroshi Ono
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdfHiroshi Ono
 

Similar a Basic info on java intro (20)

Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptx
 
Short intro to scala and the play framework
Short intro to scala and the play frameworkShort intro to scala and the play framework
Short intro to scala and the play framework
 
Aggregate Programming in Scala
Aggregate Programming in ScalaAggregate Programming in Scala
Aggregate Programming in Scala
 
Functional Programming In Jdk8
Functional Programming In Jdk8 Functional Programming In Jdk8
Functional Programming In Jdk8
 
oop unit1.pptx
oop unit1.pptxoop unit1.pptx
oop unit1.pptx
 
CS8392 OOP
CS8392 OOPCS8392 OOP
CS8392 OOP
 
Scala Introduction
Scala IntroductionScala Introduction
Scala Introduction
 
Beginning Java for .NET developers
Beginning Java for .NET developersBeginning Java for .NET developers
Beginning Java for .NET developers
 
Java1 in mumbai
Java1 in mumbaiJava1 in mumbai
Java1 in mumbai
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
 
Jslab rssh: JS as language platform
Jslab rssh:  JS as language platformJslab rssh:  JS as language platform
Jslab rssh: JS as language platform
 
JSLab.Руслан Шевченко."JavaScript как платформа компиляции"
JSLab.Руслан Шевченко."JavaScript как платформа компиляции"JSLab.Руслан Шевченко."JavaScript как платформа компиляции"
JSLab.Руслан Шевченко."JavaScript как платформа компиляции"
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
 
basic_java.ppt
basic_java.pptbasic_java.ppt
basic_java.ppt
 
C# for Java Developers
C# for Java DevelopersC# for Java Developers
C# for Java Developers
 
Developer’s viewpoint on swift programming language
Developer’s viewpoint on swift programming languageDeveloper’s viewpoint on swift programming language
Developer’s viewpoint on swift programming language
 
Multi-threading in the modern era: Vertx Akka and Quasar
Multi-threading in the modern era: Vertx Akka and QuasarMulti-threading in the modern era: Vertx Akka and Quasar
Multi-threading in the modern era: Vertx Akka and Quasar
 
Vk.amberfog.com gtug part1_introduction2_javaandroid_gtug
Vk.amberfog.com gtug part1_introduction2_javaandroid_gtugVk.amberfog.com gtug part1_introduction2_javaandroid_gtug
Vk.amberfog.com gtug part1_introduction2_javaandroid_gtug
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
 

Más de kabirmahlotra

Más de kabirmahlotra (6)

Top 10 sales trends for 2015 hbr
Top 10 sales trends for 2015   hbrTop 10 sales trends for 2015   hbr
Top 10 sales trends for 2015 hbr
 
Some presentation
Some presentationSome presentation
Some presentation
 
Pert -cpm
Pert  -cpmPert  -cpm
Pert -cpm
 
Culture9 info
Culture9 infoCulture9 info
Culture9 info
 
Chapter 1 introduction
Chapter 1 introductionChapter 1 introduction
Chapter 1 introduction
 
Basic info on java intro
Basic info on java introBasic info on java intro
Basic info on java intro
 

Último

Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxPurva Nikam
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitterShivangiSharma879191
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 

Último (20)

Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptx
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 

Basic info on java intro

  • 1. How is Java different from other languages • Less than you think: – Java is an imperative language (like C++, Ada, C, Pascal) – Java is interpreted (like LISP, APL) – Java is garbage-collected (like LISP, Eiffel, Modula-3) – Java can be compiled (like LISP) – Java is object-oriented (like C++, Ada, Eiffel) • A succesful hybrid for a specific-application domain • A reasonable general-purpose language for non-real- time applications • Work in progress: language evolving rapidly
  • 2. Original design goals (white paper 1993) • Simple • Object-oriented (inheritance, polymorphism) • Distributed • Interpreted • multithreaded • Robust • Secure • Architecture-neutral • a language with threads, objects, exceptions and garbage-collection can’t really be simple!
  • 3. Portability • Critical concern: write once-run everywhere • Consequences: – Portable interpreter – definition through virtual machine: the JVM – run-time representation has high-level semantics – supports dynamic loading – (+) high-level representation can be queried at run-time to provide reflection – (-) Dynamic features make it hard to fully compile, safety requires numerous run-time checks
  • 4. Contrast with conventional systems languages (C, C++, Ada) • Conventional languages are fully compiled: – run-time structure is machine language – minimal run-time type information – language provides low-level tools for accessing storage – safety requires fewer run-time checks because compiler – (least for Ada and somewhat for C++) can verify correctness statically. – Languages require static binding, run-time image cannot be easily modified – Different compilers may create portability problems
  • 5. Serious omissions • No parameterized classes (C++ templates, Ada generics) • Can simulate generic programming with untyped style: casting Object down into specific class. – Forces code duplication, or run-time conversions • No operator overloading (syntactic annoyance) • No enumerations (using final constants is clumsy)
  • 6. A new construct: interfaces • Allow otherwise unrelated classes to satisfy a given requirement • Orthogonal to inheritance – inheritance: an A is-a B (has the attributes of a B, and possibly others) – interface: an A can-do X (and other unrelated actions) – better model for multiple inheritance • More costly at run-time (minor consideration)
  • 7. Interface Comparable public interface Comparable { public int CompareTo (Object x) throws ClassCastException; // returns -1 if this < x, // 0 if this = x, // 1 if this > x }; // Implementation has to cast x to the proper class. // Any class that may appear in a container should implement Comparable
  • 8. Threads and their interface class Doodler extends Thread { // override the basic method of a thread public void run( ) { ... // scribble something } } … Doodler gary = new Doodler ( ); gary.start( ); // calls the run method
  • 9. The runnable interface allows any object to have dynamic behavior class Simple_Gizmo { …} class Active_Gizmo extends Simple_Gizmo implements Runnable { public void run ( ) {…} } // a thread can be constructed from anything that runs: Thread thing1 = new Thread (new Active_Gizmo ( )); Thread thing2 = new Thread (new Active_Gizmo ( )); thing1.start( ); thing2.start ( );
  • 10. Interfaces and event-driven programming • A high-level model of event-handling: – graphic objects generate events • mouse click, menu selection, window close... – an object can be designated as a handler • a listener, in Java terminology – an event can be broadcast to several handlers • several listeners can be attached to a source of events – a handler must implement an interface • actionPerformed, keyPressed, mouseExited..
  • 11. Built-in interfaces for event handlers public interface MouseListener { void mousePressed (MouseEvent event); void mouseREleased (MouseEvent event); void mouseClicked (Mouseevent event); void mouseEntered (Mouseevent event); void mouseExited (MouseEvent event); } Typically, handler only needs to process a few of the above, and supply dummy methods for the others
  • 12. Adapters: a coding convenience class mouseAdapter implements mouseListener { public void mousePressed (MouseEvent event) { } ; public void mouseREleased (MouseEvent event) { }; public void mouseClicked (Mouseevent event) { }; public void mouseEntered (Mouseevent event) { }; public void mouseExited (MouseEvent event) { }; }; class MouseClickListener extends Mouseadapter { public void mouseClicked (MouseEvent event {…}; // only the method of interest needs to be supplied }
  • 13. Events and listeners class Calm_Down extends Jframe { private Jbutton help := new Jbutton (“HELP!!!”); // indicate that the current frame handles button clicks help.addActionListener (this); // if the button is clicked the frame executes the following: public void actionPerformed (ActionEvent e) { if (e.getSource () == help) { System.out.println (“can’t be that bad. What’s the problem?”); } } }
  • 14. Event handlers and nested classes • Inner classes make it possible to add local handlers to any component class reactive_panel extends Jpanel { // a swing component JButton b1; Public reactive_panel (Container c) { b1 = new JButton (“flash”); add (b1); MyListener ml = new Mylistener ( ) ; b1.addActionListener (ml); private class MyListener implements ActionListener { public void actionPerformed (ActionEvent e) { …} }
  • 15. Introspection, reflection, and typeless programming public void DoSomething (Object thing) { // what can be do with a generic object? if (thing instanceof gizmo) { // we know the methods in class Gizmo …. • Instanceof requires an accessible run-time descriptor in the object. • Reflection is a general programming model that relies on run- time representations of aspects of the computation that are usually not available to the programmer. • More common in Smalltalk and LISP.
  • 16. Reflection and metaprogramming • Given an object at run-time, it is possible to obtain: – its class – its fields (data members) as strings – the classes of its fields – the methods of its class, as strings – the types of the methods • It is then possible to construct calls to these methods • This is possible because the JVM provides a high- level representation of a class, with embedded strings that allow almost complete disassembly.
  • 17. Reflection classes • java.lang.Class – Class.getMethods () returns array of method objects – Class.getConstructor (Class[ ] parameterTypes) • returns the constructor with those parameters • java.lang.reflect.Array – Array.NewInstance (Class componentType, int length) • java.lang.reflect.Field • java.lang.reflect.Method • All of the above require the existence of run-time objects that describe methods and classes
  • 18. Reflection and Beans • The beans technology requires run-time examination of foreign objects, in order to build dynamically a usable interface for them. • Class Introspector builds a method dictionary based on simple naming conventions: public boolean isCoffeeBean ( ); // is... predicate public int getRoast ( ); // get... retrieval public void setRoast (int darkness) ; // set… assignment
  • 19. An endless supply of libraries • The power of the language is in the large set of libraries in existence. The language is successful if programmers find libraries confortable: • JFC and the Swing package • Pluggable look and Feel • Graphics • Files and Streams • Networking • Enterprise libraries: CORBA, RMI, Serialization, JDBC