Introduction to Object Oriented Programming (OOP)
|
|
|
- Sharleen Floyd
- 9 years ago
- Views:
Transcription
1 Introduction to Object Oriented Programming (OOP) Sept. 21, 2005 by Dr. Lyle N. Long Professor of Aerospace Engineering The Pennsylvania State University, University Park, PA
2 Outline Computer Languages Characteristics of OOP: Encapsulation Inheritance Polymorphism C++ Java Conclusions 2 L.N.Long
3 3 L.N.Long Programming Languages C++ will remain the pre-eminent language for very large software projects. Extremely difficult language. Lot of room for errors. Not fully object oriented (has to carry the C legacy). Java's importance is growing rapidly, it has become the language of choice for internet and intranet applications, including small devices. It's role has spread to many applications (refrigerators, cell phones, watches, supercomputers,...). Java has many features not available in C++, and does not have some of the problems of C++. Fortran, Pascal, Cobol, Ada and other languages will be niche markets. (F95 is immensely better than F77). They will remain for some time, due to the huge installed base of programs, but new programs will (most likely) be written in C++ or Java.
4 Free Expensive Programming C++ Java or C# C Fortran 95 Basic Perl Matlab / Mathematica Spreadsheet Increasing Complexity and Capability For most small programming jobs, Matlab is great (builtin graphics, linear algebra, math functions, ), for most large projects C++ (or Java) might be best. Fortran is best for almost no job. 4 L.N.Long
5 Effort, Software Size, & Complexity Procedural (e.g. Fortran) Effort OOP (e.g. C++) Size and Complexity 5 L.N.Long
6 Key OOP Languages C++ Java C# (windows only) Ada95 Smalltalk Eiffel Simula 6 L.N.Long
7 Introduction C++ is an ANSI standard now (1998) C++ is built for speed and power. As a programmer you can usually do whatever you want, and the compiler will not second guess you. So you can get into trouble very easily. For example, array indices are not checked at compile or run-time. So if you want to do: int x[100]; x[-10] = 900; x[200] = 9; the compiler will often let you!! You can easily corrupt computer memory. Likewise with pointers and dynamic memory you can get into trouble (eg memory leaks). 7 L.N.Long
8 Introduction (cont.) The main elements of C++ that are different than Java are: Compilers Pointers Memory handling Structures Classes Operator Overloading Input / Output Libraries Legacy with C 8 L.N.Long
9 Object Oriented Programming OOP allows programmers to more closely model the real world than ever before. Rapid prototyping. Object-Oriented programs can be built and modified very quickly because it provides the programmer with excellent tools for abstraction. OOP produces reusable code. Once objects are built, it is very easy to use them in future applications so you need not ever reinvent the wheel. OOP helps programmers work in dynamic environments. Object- Oriented programs can be modified quickly and easily as real-world requirements change. OOP lets you build large complex codes our of small manageable pieces of code 9 L.N.Long
10 C++ and Java Don t forget that it is very easy to write bad code in any language. Writing good code is an art, and requires lots of experience. I would actually rather have a really well written code in Fortran than a bad C++ code Also, C++ gives you the capability to program with reckless abandon. With pointers, you can often change the value of any memory location in the machine! Even if the OS really needs that data! C++ is better than Fortran, but it is hard to learn to do it well If you are going to use C++ you have to be serious about programming. Java is more forgiving. 10 L.N.Long
11 A Few Facts About Java (from Scott McNealy, CEO Sun) Java is only 9 years old 25,000 people attended the JavaOne Conference in million Java programmers (expect 4 million by 2003) 5 million downloads of Java Development Kit (JDK) 1.1 million visitors per month at java.sun.com 80% of universities teach Java (50% of these have it required) 2000 Java Books published 50% of programmers use Java 11 L.N.Long
12 Java Features Object oriented Graphical user interfaces Remote method invocation Graphics Serial port drivers Fairly machine independent Multi-threaded Java docs 12 L.N.Long
13 Java Features Object oriented Graphical user interfaces Remote method invocation Graphics Serial port drivers Fairly machine independent Multi-threaded Java docs C++ FLTK CORBA or Sockets OpenGL Open source software Compilers POSIX threads Doxygen 13 L.N.Long
14 Java Java has definitely been oversold C, C++ and Ada all have their place Easy to generate bad C++ code Ada is good, but never caught on (outside of DOD) Java suffered early on with performance and scalability problems mysql and PHP might be better for many web applications But new Java processors and embedded computing apps are well suited to Java And it is easier to use Java instead of C++ + FLTK + CORBA + POSIX + OpenGL + 14 L.N.Long
15 15 L.N.Long Measuring language popularity using SourceForge
16 16 L.N.Long Measuring language popularity using Altavista hits
17 Object Oriented Programming OOP: Inheritance, polymorphism, and encapsulation Inheritance: Objects can inherit the properties of other objects. We can create mammal objects, and dogs and cats can be new objects that simply inherit the properties of the mammals. Polymorphism: You can write functions that behave differently depending on what kind of data is passed to them. E.g. you could make a sqrt function that would work with integers, floats, or even complex numbers. You could also create a run() method for mammals that would work fine for cats or dogs. Encapsulation: Data and methods (ie functions) are stored together in a class. Code becomes modifiable, understandable, and portable. 17 L.N.Long
18 Encapsulation In OOP the data and methods associated with objects are normally hidden from the users Objects communicate with each other thru welldefined interfaces The details of the code are not available outside the class, the author decides what others can see, modify, and use. Variables (data) can be Public, Protected, Private, 18 L.N.Long
19 Inheritance Inheritance permits software reusability New classes can be created from old classes The attributes (data) and behavior (methods) of the old class are available to the new class New data and methods can be added to the new class also Inheritance allows you to write key pieces of code once and use it over and over This can get kind of confusing, just remember you can write lots of simple little C++ or Java programs without using inheritance and polymorphism (and you will often be using them without knowing it!) 19 L.N.Long
20 Polymorphism An object s ability to decide what method to apply to itself, depending on where it is in the inheritance heirarchy, is usually called polymorphism. The idea behind polymorphism is that while the message may be the same, objects may respond differently. (From Core Java book ) This is why I referred to it as method overloading on steroids. (i.e. it is more powerful than simply method overloading) The key to making polymorphism work is dynamic binding. When you apply a method to an object it decides at run time what to do, it is not decided when the code is compiled (static binding). 20 L.N.Long
21 Polymorphism (cont.) Polymorphism allows you to avoid very complicated switch or if/else constructs that are required in other languages to treat special cases The same method name can be used in many different ways by different objects, this is especially interesting for inherited objects Method overloading Ideally we would like to have the power to loop thru our objects as though they were all the same, but have the right data and methods used in all subclasses For example, what if I had lots of shapes (circles, squares,..) and I wanted to animate them on the screen. I can simply loop thru all Shape objects and do that! Without the need for any switch statements. 21 L.N.Long
22 class: A Few Terms A class is a blueprint for how to make an object method: A function (defined in a class) data numbers, arrays, objects, (defined in a class) object: An instance of a class dot notation: mycat.size (this could return the size of a cat) mycat.run() (this could make the cat run) System.out.println() (can have more than one dot) Arrays of Objects mycats[i][j] 22 L.N.Long
23 HelloWorld Java Program public class HelloWorld { public static void main ( String args[] ){ System.out.println( "Hello World!"); } } Store the above in a file called HelloWorld.java then do: javac HelloWorld.java then do: java HelloWorld 23 L.N.Long
24 C++ Hello World preprocessor command #include <iostream.h> OR int main(void) { } cout << Hello World! << endl; return 0; optional (0 = success) #include <iostream.h> int main(void){cout << Hello World! <<endl;return 0;} (don t do this) 24 L.N.Long
25 Object Oriented Programming (OOP) OOP encapsulates data (e.g. numbers and objects) and methods (functions) Information hiding is a key aspect of OOP Implementation details are hidden from the user ( we can drive a car without knowing how it is built ) C and Fortran are action oriented (verbs) Java is object oriented (nouns) C++ can be in between...pure C code will compile in a C++ compiler 25 L.N.Long
26 Modifiability Readability Benefits of OOP Maintainability Reliability Reusability... the ilities Languages such as Fortran are fine for relatively small programs when you are only interested in number crunching (FORmula TRANslation). But for large programming tasks, it is a clunky old language (without graphics, GUI s, threads, OOP, and networking,...). 26 L.N.Long
27 OOP To create an instance of this class (an object), do: Molecule x = new Molecule(); public class Molecule { public double u, v, w ; public double maxvelocity () { double max; max = Math.max ( u, v ); max = Math.max ( max, w ) ; return max; } To use u you could do: } newu = x.u To use the method: vmax = x.maxvelocity() 27 L.N.Long
28 Objects and Pointers Don t forget about the new notation, we are used to this: Molecule a; a.x = 3.0; (if x is public) But what if you have a pointer to an object: Molecule * b; (b is a pointer to a Molecule ) now you cannot do this, since b is not a Molecule: b.x = 3.0 you have to do this: b->x = 3.0; Similarly for class methods: b->move(); 28 L.N.Long
29 29 L.N.Long Class Example class Molecule { private: double x,y,z; double u,v,w; char * name; int atoms; static double dt; static int total; }; public: void move() { x = x + dt * u; y = y + dt * v; z = z + dt * w; } optional. these will be private even if the keyword private is not there. // molecule location // molecule velocity // molecule name (e.g. H2O) // number of atoms // simulation time step // number of molecules a common mistake is to omit the semicolon
30 Private and Public We usually use private class variables, which means only class methods can use them (private variables are recommended, otherwise encapsulation is broken) If you use public variables, then users can simply do: myobject.x = 2.0; this is bad. use set and get methods instead. myobject.setx( 2.0 ); It can seem like a lot of additional work, but will help you make better code, and it will give you more freedom to modify the code in the future 30 L.N.Long
31 Get and Set Methods Instead of giving people access to your class data, you should supply get and set methods. class Molecule { private: double u,v,w; public: void setu ( double Veloc ) { u = Veloc;} double getu () {return u;} void setv ( double Veloc ) { v = Veloc;} double getv () {return v;} void setw ( double Veloc ) { w = Veloc;} double getw () {return w;} } 31 L.N.Long
32 Constructors and Destructors To use C++ classes, you also need to understand constructors and destructors We will see constructors in Java, but not destructors Constructors are simply methods that tell C++ how to create instances of objects, and these can be overloaded as in Java Destructors are needed because memory management is left to the programmer in C++. So often a destructor will be used to delete the memory associated with an object that is being deleted. If your objects don t use dynamic memory (ie pointers) then you don t have to worry about this too much. If you do not provide a constructor or destructor, the system will use the default ones. (which do little or nothing) The data values will have random values (not zeroes and NULL s as Java does) 32 L.N.Long
33 Constructors Methods with the same name as the class are constructors There are often several different constructors (i.e. they can be over-loaded) You don t have to have constructors, but they are usually a good idea. A default constructor is automatically included. If you have any constructors, then there is no default constructor Constructors cannot return a value If the arguments in a new statement do not match any constructor this is an error If a default constructor is used, then you can t be sure how the data is initialized. Null Pointer Exception errors are often due to errors in constructors 33 L.N.Long
34 OVERLOADED class Molecule { CONSTRUCTORS private: double x[3]; double u[3]; public: Molecule (){ x = { 0.0, 0.0, 0.0 }; u = { 0.0, 0.0, 0.0 }; } Molecule (double xx, double yy, double zz){ x[0] = xx; x[1] = yy; x[2] = zz; u = { 0.0, 0.0, 0.0 }; }... } 34 L.N.Long
35 Class Destructor Example class Molecule { private: double x,y,z; double u,v,w; char * name; int atoms; static double dt; static int total; public: void move(); Notice the tilde ~ }; // molecule location // molecule velocity // molecule name (e.g. H2O) // number of atoms // this is now a prototype Molecule(); // prototype for constructor Molecule(double x, double y, double z); //prototype ~Molecule(); // prototype for destructor 35 L.N.Long
36 Class Destructor Example inline Molecule::~Molecule() { total = total - 1; delete name; } If you write a destructor, then you usually should also write a copy constructor and an assignment operator. This lets you keep an accurate count of how many molecules you have. Since name is a pointer to a char or an array of char s (ie a string), you need to make sure you remove that memory if you delete a Molecule object. If you do not do this, then you will have a memory leak. destructors can take no arguments and can return no values. 36 L.N.Long
37 METHODS Functions. You have already seen some: System.out.println ( Hello ) ; Math.sqrt ( 12.0 ) ; g.drawstring ( Hello, 20, 20 ); Methods are key pieces of Objects (the other is data) that you can create Divide and conquer!! Break your program up into well-defined and easy to debug pieces! This also makes it easier to reuse software. 37 L.N.Long
38 Method Overloading Java does not allow operator overloading (C++ does), but it does allow method overloading For example: public class MethodExample extends Japplet { public void init () { put code here... } public double square ( double y ) { return y * y; } public int square ( int y ) { return y * y; } } You can now call the method square and pass it an int or a double and it will use the correct version of the method. It will not work if you pass it a float. 38 L.N.Long
39 Has-a and Is-a Engine has-a Vehicle Boat is-a Aircraft Ground Vehicle Carrier Sailboat Submarine Helo Transport Glider Truck Car Vehicle has-a engine (containment) Aircraft is-a vehicle (inheritance) Don t confuse containment with inheritance 39 L.N.Long
40 Has-a and Is-a We could define a Molecule class such as: class Atom { private: 40 L.N.Long public: } class Molecule { private: public: double x, y, z, xold, yold, zold, xnew, ynew, znew;//position double u, v, w; // velocity double ax, ay, az; // acceleration double mass, invmass; // particle mass & 1/mass static double timestep; // global time step static double totalnumber; // total number of particles char * name; // string for name... Atom * atoms;... } When it appears in the data, we would say: Molecule has-a Atom So, for example, we could have a water molecule made up of two oxygen and one hydrgen atoms. Since atoms is a pointer, we could dynamically assign the atoms to each molecule.
41 Has-a and Is-a We could also define a Molecule class such as: class Particle { protected: double x, y, z, xold, yold, zold, xnew, ynew, znew;//position double u, v, w; // velocity double ax, ay, az; // acceleration double mass, invmass; // particle mass & 1/mass static double timestep; // global time step static double totalnumber; // total number of particles char * name; // string for name public:... } class Atom : public Particle { } C++ Inheritance. We would say: Atom is-a Particle Inheritance! 41 L.N.Long
42 Example METHODS: print giveraise Penn State Person METHODS: print Employee Student Alumni Donors Faculty Staff Grad Administrator Teacher 42 L.N.Long Undergrad METHODS: print giveraise promote denytenure METHODS: print giveraise promote denytenure doresearch
43 Example Code: objects.cpp Person METHODS: print METHODS: print Employee Student Faculty Staff Administrator Lets look at the code 43 L.N.Long
44 In C++ the print() method will need to be defined as virtual. int main() { int i; Using Polymorphism Student nilay(25,66.0,"nilay",13); Faculty lyle(48,68.0,"lyle", ,"professor"); Staff tom(35,69.0,"tom", ,200); Administrator graham(53,69.0,"graham", ,"professor","president"); Person * people; This will call the proper print method NOT the Person print method 44 L.N.Long } people[0] = new Student; people[0] = &nilay; people[1] = new Faculty; people[1] = &lyle; people[2] = new Staff; people[2] = &tom; people[3] = new Administrator; people[3] = &graham; for ( i = 0 ; i < 4 ; i++) { people[i]->print(); cout << endl; } very powerful. we now have an array full of all kinds of different objects. But yet we can treat them as though they were all similar!
45 Private, Protected, and Public If you were really paying attention, you will have noticed the keyword protected used for data members (instead of private) Private: Data or methods are not visible to instances of objects of this class Data or methods are visible to member functions of the class (eg Get and Set methods) Protected: Data or methods are visible to this class and to all classes derived from this class Public: If a function has an object of a certain class, then it can access all the public data or methods of that class 45 L.N.Long
46 C++ Keywords Storage: char short int long float double bool signed unsigned struct union class enum auto static register extern volatile const typedef void sizeof Control: if while switch continue else for case break goto default return do Other: true false asm friend public private protected try catch throw new delete virtual inline operator template this More: auto, register, volatile, sizeof, asm, virtual, template 46 L.N.Long
47 47 L.N.Long Java Keywords abstract boolean break byte case catch char class continue default do double else extends false final finally float for if implements import instanceof int Interface long native new null package private protected public return short static super switch synchronized this throw throws transient true try void volatile while
48 Bruce Eckel s Thinking in C++ (free on-line book) Win32 Compilers A note about Visual C++. I periodically receive messages saying that the most recent version of Visual C++ will not compile many of the programs in the book. Let me attempt to be diplomatic here. Microsoft has stated that what they are creating is "a Windows compiler." Their interest is in creating a compiler that makes Windows programs, and not one that is compliant to the C++ Standard. As a result, the Standard C++ features in VC++ have been increasing at a relative crawl, and you should not expect VC++ to compile many of the programs in the book. The complete listing of files that will not compile can be found in the file CompilerData.txt in both volumes. If you find a problem with a program and VC++, it is extremely likely that it is a deficiency in VC++ and not in the code listing. A Microsoft makefile is included that will successfully compile all possible programs in the book L.N.Long
49 ARRAYS OF OBJECTS If we have a class such as: public Person { int age; double height; String job; } We can create an array of these via: Person[] group = new Person[20]; With just this you will get a null pointer exception But the above is not enough to allow us to use this array, we need to initialize this array, maybe via: for ( int i = 0 ; i < 20 ; i++ ) group[i] = new Person(); A way to remember this is that this one has ( ) which indicates a method (a constructor) is used. 49 L.N.Long
50 Parallel/Distributed Computing Message Passing Interface (MPI) ( ) Fortran C Java C++ (but object data must be packed into structs for MPI) Common Object Request Broker Architecture (CORBA) ( C++, Java, and others Remote Method Invocation (RMI) ( ) Java Unix Socket Programming Others? DDS? 50 L.N.Long
51 CONCLUSIONS Object oriented programming is extremely common now There are at least 150 books on OOP If done well, it can lead to much better code in a shorter period of time As discussed in Core Java, companies like Dell and Compaq became very successful by buying large quantities of PC components and building PC s. (in fact Dell does not even make their own laptops, and they aren t very good). They do not build all the pieces. Likewise when you write a Java program you ought to use well-built pieces that exist. Since the programmer has to manage all the dynamic memory in C++, using objects can be quite a bit more challenging But keep in mind that you do not have to use all the features of C++ right away, you can slowly start using dynamic memory in your codes (and in some cases you may not need it...fortran did without it for forty years...) 51 L.N.Long
52 References C++ and Object-Oriented Numeric Computing, D. Yang "Core C++," by Shtern, Prentice Hall Practical C++ Programming, by Oualline, O Reilly Press C++ How to Program," by Deitel and Deitel, Prentice Hall C++ Gotchas, by Dewhurst Java for Scientists and Engineers, 2 nd Edition, by S. Chapman "Core Java," Volume I, by Horstmann and Cornell, Prentice Hall "Java How to Program," by Deitel and Deitel, Prentice Hall "Core Web Programming," by Hall, Prentice Hall java.sun.com 52 L.N.Long
53 53 L.N.Long
Introduction to Object Oriented Programming (OOP)
Introduction to Object Oriented Programming (OOP) Oct. 6, 2008 by Dr. Lyle N. Long Distinguished Professor of Aerospace Engineering The Pennsylvania State University, University Park, PA 16802 Outline
First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science
First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca
Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives
Introduction to Programming and Algorithms Module 1 CS 146 Sam Houston State University Dr. Tim McGuire Module Objectives To understand: the necessity of programming, differences between hardware and software,
Chapter 1 Java Program Design and Development
presentation slides for JAVA, JAVA, JAVA Object-Oriented Problem Solving Third Edition Ralph Morelli Ralph Walde Trinity College Hartford, CT published by Prentice Hall Java, Java, Java Object Oriented
C++ INTERVIEW QUESTIONS
C++ INTERVIEW QUESTIONS http://www.tutorialspoint.com/cplusplus/cpp_interview_questions.htm Copyright tutorialspoint.com Dear readers, these C++ Interview Questions have been designed specially to get
Object Oriented Software Design II
Object Oriented Software Design II Introduction to C++ Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 20, 2012 G. Lipari (Scuola Superiore Sant Anna) C++ Intro February
An Incomplete C++ Primer. University of Wyoming MA 5310
An Incomplete C++ Primer University of Wyoming MA 5310 Professor Craig C. Douglas http://www.mgnet.org/~douglas/classes/na-sc/notes/c++primer.pdf C++ is a legacy programming language, as is other languages
Java Interview Questions and Answers
1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write and compile the java
An Overview of Java. overview-1
An Overview of Java overview-1 Contents What is Java Major Java features Java virtual machine Java programming language Java class libraries (API) GUI Support in Java Networking and Threads in Java overview-2
PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?
1. Distinguish & and && operators. PART-A Questions 2. How does an enumerated statement differ from a typedef statement? 3. What are the various members of a class? 4. Who can access the protected members
Fundamentals of Java Programming
Fundamentals of Java Programming This document is exclusive property of Cisco Systems, Inc. Permission is granted to print and copy this document for non-commercial distribution and exclusive use by instructors
KITES TECHNOLOGY COURSE MODULE (C, C++, DS)
KITES TECHNOLOGY 360 Degree Solution www.kitestechnology.com/academy.php [email protected] [email protected] Contact: - 8961334776 9433759247 9830639522.NET JAVA WEB DESIGN PHP SQL, PL/SQL
The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1
The Java Series Java Essentials I What is Java? Basic Language Constructs Slide 1 What is Java? A general purpose Object Oriented programming language. Created by Sun Microsystems. It s a general purpose
Pemrograman Dasar. Basic Elements Of Java
Pemrograman Dasar Basic Elements Of Java Compiling and Running a Java Application 2 Portable Java Application 3 Java Platform Platform: hardware or software environment in which a program runs. Oracle
Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C
Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C 1 An essential part of any embedded system design Programming 2 Programming in Assembly or HLL Processor and memory-sensitive
Introduction to Object-Oriented Programming
Introduction to Object-Oriented Programming Objects and classes Abstract Data Types (ADT) Encapsulation and information hiding Aggregation Inheritance and polymorphism OOP: Introduction 1 Pure Object-Oriented
CSE 452: Programming Languages. Acknowledgements. Contents. Java and its Evolution
CSE 452: Programming Languages Java and its Evolution Acknowledgements Rajkumar Buyya 2 Contents Java Introduction Java Features How Java Differs from other OO languages Java and the World Wide Web Java
Evolution of the Major Programming Languages
142 Evolution of the Major Programming Languages Object Oriented Programming: Smalltalk Object-Oriented: It s fundamental characteristics are: Data abstraction, Inheritance and Dynamic Binding. The essence
JAVA - QUICK GUIDE. Java SE is freely available from the link Download Java. So you download a version based on your operating system.
http://www.tutorialspoint.com/java/java_quick_guide.htm JAVA - QUICK GUIDE Copyright tutorialspoint.com What is Java? Java is: Object Oriented Platform independent: Simple Secure Architectural- neutral
History OOP languages Year Language 1967 Simula-67 1983 Smalltalk
History OOP languages Intro 1 Year Language reported dates vary for some languages... design Vs delievered 1957 Fortran High level programming language 1958 Lisp 1959 Cobol 1960 Algol Structured Programming
Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C
Basic Java Constructs and Data Types Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C 1 Contents Hello World Program Statements Explained Java Program Structure in
Crash Course in Java
Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J. Johns also: Java in a Nutshell Java Network Programming and Distributed Computing Netprog 2002 Java Intro 1 What is
The programming language C. sws1 1
The programming language C sws1 1 The programming language C invented by Dennis Ritchie in early 1970s who used it to write the first Hello World program C was used to write UNIX Standardised as K&C (Kernighan
C++ Programming Language
C++ Programming Language Lecturer: Yuri Nefedov 7th and 8th semesters Lectures: 34 hours (7th semester); 32 hours (8th semester). Seminars: 34 hours (7th semester); 32 hours (8th semester). Course abstract
Java CPD (I) Frans Coenen Department of Computer Science
Java CPD (I) Frans Coenen Department of Computer Science Content Session 1, 12:45-14:30 (First Java Programme, Inheritance, Arithmetic) Session 2, 14:45-16:45 (Input and Programme Constructs) Materials
Java Programming Fundamentals
Lecture 1 Part I Java Programming Fundamentals Topics in Quantitative Finance: Numerical Solutions of Partial Differential Equations Instructor: Iraj Kani Introduction to Java We start by making a few
Multichoice Quetions 1. Atributes a. are listed in the second part of the class box b. its time is preceded by a colon. c. its default value is
Multichoice Quetions 1. Atributes a. are listed in the second part of the class box b. its time is preceded by a colon. c. its default value is preceded by an equal sign d. its name has undereline 2. Associations
Contents. Java - An Introduction. Java Milestones. Java and its Evolution
Contents Java and its Evolution Rajkumar Buyya Grid Computing and Distributed Systems Lab Dept. of Computer Science and Software Engineering The University of Melbourne http:// www.buyya.com Java Introduction
Installing Java (Windows) and Writing your First Program
Appendix Installing Java (Windows) and Writing your First Program We will be running Java from the command line and writing Java code in Notepad++ (or similar). The first step is to ensure you have installed
El Dorado Union High School District Educational Services
El Dorado Union High School District Course of Study Information Page Course Title: ACE Computer Programming II (#495) Rationale: A continuum of courses, including advanced classes in technology is needed.
13 Classes & Objects with Constructors/Destructors
13 Classes & Objects with Constructors/Destructors 13.1 Introduction In object oriented programming, the emphasis is on data rather than function. Class is a way that binds the data & function together.
CSC 551: Web Programming. Spring 2004
CSC 551: Web Programming Spring 2004 Java Overview Design goals & features platform independence, portable, secure, simple, object-oriented, Programming models applications vs. applets vs. servlets intro
AP Computer Science Java Subset
APPENDIX A AP Computer Science Java Subset The AP Java subset is intended to outline the features of Java that may appear on the AP Computer Science A Exam. The AP Java subset is NOT intended as an overall
Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.
Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to
Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C
Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection
Introduction Object-Oriented Network Programming CORBA addresses two challenges of developing distributed systems: 1. Making distributed application development no more dicult than developing centralized
Java SE 8 Programming
Oracle University Contact Us: 1.800.529.0165 Java SE 8 Programming Duration: 5 Days What you will learn This Java SE 8 Programming training covers the core language features and Application Programming
Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)
Unit- I Introduction to c Language: C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating
The C Programming Language course syllabus associate level
TECHNOLOGIES The C Programming Language course syllabus associate level Course description The course fully covers the basics of programming in the C programming language and demonstrates fundamental programming
Introduction to Java
Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high
Characteristics of Java (Optional) Y. Daniel Liang Supplement for Introduction to Java Programming
Characteristics of Java (Optional) Y. Daniel Liang Supplement for Introduction to Java Programming Java has become enormously popular. Java s rapid rise and wide acceptance can be traced to its design
Java (12 Weeks) Introduction to Java Programming Language
Java (12 Weeks) Topic Lecture No. Introduction to Java Programming Language 1 An Introduction to Java o Java as a Programming Platform, The Java "White Paper" Buzzwords, Java and the Internet, A Short
C++FA 5.1 PRACTICE MID-TERM EXAM
C++FA 5.1 PRACTICE MID-TERM EXAM This practicemid-term exam covers sections C++FA 1.1 through C++FA 1.4 of C++ with Financial Applications by Ben Van Vliet, available at www.benvanvliet.net. 1.) A pointer
A deeper look at Inline functions
A deeper look at Inline functions I think it s safe to say that all Overload readers know what C++ inline functions are. When we declare a function or member function as inline we are trying to avoid the
Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas
CS 110B - Rule Storage Classes Page 18-1 Attributes are distinctive features of a variable. Data type, int or double for example, is an attribute. Storage class is another attribute. There are four storage
COS 217: Introduction to Programming Systems
COS 217: Introduction to Programming Systems 1 Goals for Todayʼs Class Course overview Introductions Course goals Resources Grading Policies Getting started with C C programming language overview 2 1 Introductions
Course Name: ADVANCE COURSE IN SOFTWARE DEVELOPMENT (Specialization:.Net Technologies)
Course Name: ADVANCE COURSE IN SOFTWARE DEVELOPMENT (Specialization:.Net Technologies) Duration of Course: 6 Months Fees: Rs. 25,000/- (including Service Tax) Eligibility: B.E./B.Tech., M.Sc.(IT/ computer
Tutorial: Getting Started
9 Tutorial: Getting Started INFRASTRUCTURE A MAKEFILE PLAIN HELLO WORLD APERIODIC HELLO WORLD PERIODIC HELLO WORLD WATCH THOSE REAL-TIME PRIORITIES THEY ARE SERIOUS SUMMARY Getting started with a new platform
The Java Virtual Machine and Mobile Devices. John Buford, Ph.D. [email protected] Oct 2003 Presented to Gordon College CS 311
The Java Virtual Machine and Mobile Devices John Buford, Ph.D. [email protected] Oct 2003 Presented to Gordon College CS 311 Objectives Review virtual machine concept Introduce stack machine architecture
INTRODUCTION TO COMPUTER PROGRAMMING. Richard Pierse. Class 7: Object-Oriented Programming. Introduction
INTRODUCTION TO COMPUTER PROGRAMMING Richard Pierse Class 7: Object-Oriented Programming Introduction One of the key issues in programming is the reusability of code. Suppose that you have written a program
Programming by Contract. Programming by Contract: Motivation. Programming by Contract: Preconditions and Postconditions
COMP209 Object Oriented Programming Designing Classes 2 Mark Hall Programming by Contract (adapted from slides by Mark Utting) Preconditions Postconditions Class invariants Programming by Contract An agreement
Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.
Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java
language 1 (source) compiler language 2 (target) Figure 1: Compiling a program
CS 2112 Lecture 27 Interpreters, compilers, and the Java Virtual Machine 1 May 2012 Lecturer: Andrew Myers 1 Interpreters vs. compilers There are two strategies for obtaining runnable code from a program
ECE 122. Engineering Problem Solving with Java
ECE 122 Engineering Problem Solving with Java Introduction to Electrical and Computer Engineering II Lecture 1 Course Overview Welcome! What is this class about? Java programming somewhat software somewhat
public static void main(string[] args) { System.out.println("hello, world"); } }
Java in 21 minutes hello world basic data types classes & objects program structure constructors garbage collection I/O exceptions Strings Hello world import java.io.*; public class hello { public static
Part I. Multiple Choice Questions (2 points each):
Part I. Multiple Choice Questions (2 points each): 1. Which of the following is NOT a key component of object oriented programming? (a) Inheritance (b) Encapsulation (c) Polymorphism (d) Parallelism ******
Compiling Object Oriented Languages. What is an Object-Oriented Programming Language? Implementation: Dynamic Binding
Compiling Object Oriented Languages What is an Object-Oriented Programming Language? Last time Dynamic compilation Today Introduction to compiling object oriented languages What are the issues? Objects
Chapter 1 Fundamentals of Java Programming
Chapter 1 Fundamentals of Java Programming Computers and Computer Programming Writing and Executing a Java Program Elements of a Java Program Features of Java Accessing the Classes and Class Members The
Infrastructure that supports (distributed) componentbased application development
Middleware Technologies 1 What is Middleware? Infrastructure that supports (distributed) componentbased application development a.k.a. distributed component platforms mechanisms to enable component communication
1 Abstract Data Types Information Hiding
1 1 Abstract Data Types Information Hiding 1.1 Data Types Data types are an integral part of every programming language. ANSI-C has int, double and char to name just a few. Programmers are rarely content
Moving from CS 61A Scheme to CS 61B Java
Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you
Lecture 7 Notes: Object-Oriented Programming (OOP) and Inheritance
Introduction to C++ January 19, 2011 Massachusetts Institute of Technology 6.096 Lecture 7 Notes: Object-Oriented Programming (OOP) and Inheritance We ve already seen how to define composite datatypes
INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011
INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011 1 Goals of the Lecture Present an introduction to Objective-C 2.0 Coverage of the language will be INCOMPLETE
Object Oriented Software Design
Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa September 14, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction
What is COM/DCOM. Distributed Object Systems 4 COM/DCOM. COM vs Corba 1. COM vs. Corba 2. Multiple inheritance vs multiple interfaces
Distributed Object Systems 4 COM/DCOM Piet van Oostrum Sept 18, 2008 What is COM/DCOM Component Object Model Components (distributed objects) à la Microsoft Mainly on Windows platforms Is used in large
6.088 Intro to C/C++ Day 4: Object-oriented programming in C++ Eunsuk Kang and Jean Yang
6.088 Intro to C/C++ Day 4: Object-oriented programming in C++ Eunsuk Kang and Jean Yang Today s topics Why objects? Object-oriented programming (OOP) in C++ classes fields & methods objects representation
Sources: On the Web: Slides will be available on:
C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,
Introduction to Scientific Computing Part II: C and C++ C. David Sherrill School of Chemistry and Biochemistry Georgia Institute of Technology
Introduction to Scientific Computing Part II: C and C++ C. David Sherrill School of Chemistry and Biochemistry Georgia Institute of Technology The C Programming Language: Low-level operators Created by
Java applets. SwIG Jing He
Java applets SwIG Jing He Outline What is Java? Java Applications Java Applets Java Applets Securities Summary What is Java? Java was conceived by James Gosling at Sun Microsystems Inc. in 1991 Java is
Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program
Free Java textbook available online "Thinking in Java" by Bruce Eckel, 4th edition, 2006, ISBN 0131872486, Pearson Education Introduction to the Java programming language CS 4354 Summer II 2015 The third
UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming
UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming 1 2 Foreword First of all, this book isn t really for dummies. I wrote it for myself and other kids who are on the team. Everything
Software Engineering Techniques
Software Engineering Techniques Low level design issues for programming-in-the-large. Software Quality Design by contract Pre- and post conditions Class invariants Ten do Ten do nots Another type of summary
Syllabus for CS 134 Java Programming
- Java Programming Syllabus Page 1 Syllabus for CS 134 Java Programming Computer Science Course Catalog 2000-2001: This course is an introduction to objectoriented programming using the Java language.
Basic Programming and PC Skills: Basic Programming and PC Skills:
Texas University Interscholastic League Contest Event: Computer Science The contest challenges high school students to gain an understanding of the significance of computation as well as the details of
Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program
Free Java textbook available online "Thinking in Java" by Bruce Eckel, 4th edition, 2006, ISBN 0131872486, Pearson Education Introduction to the Java programming language CS 4354 Summer II 2014 Jill Seaman
IS0020 Program Design and Software Tools Midterm, Feb 24, 2004. Instruction
IS0020 Program Design and Software Tools Midterm, Feb 24, 2004 Name: Instruction There are two parts in this test. The first part contains 50 questions worth 80 points. The second part constitutes 20 points
C++FA 3.1 OPTIMIZING C++
C++FA 3.1 OPTIMIZING C++ Ben Van Vliet Measuring Performance Performance can be measured and judged in different ways execution time, memory usage, error count, ease of use and trade offs usually have
Glossary of Object Oriented Terms
Appendix E Glossary of Object Oriented Terms abstract class: A class primarily intended to define an instance, but can not be instantiated without additional methods. abstract data type: An abstraction
Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007
Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007 The Java Type System By now, you have seen a fair amount of Java. Time to study in more depth the foundations of the language,
CORBA Programming with TAOX11. The C++11 CORBA Implementation
CORBA Programming with TAOX11 The C++11 CORBA Implementation TAOX11: the CORBA Implementation by Remedy IT TAOX11 simplifies development of CORBA based applications IDL to C++11 language mapping is easy
Course Title: Software Development
Course Title: Software Development Unit: Customer Service Content Standard(s) and Depth of 1. Analyze customer software needs and system requirements to design an information technology-based project plan.
C# and Other Languages
C# and Other Languages Rob Miles Department of Computer Science Why do we have lots of Programming Languages? Different developer audiences Different application areas/target platforms Graphics, AI, List
How To Write A Program In Java (Programming) On A Microsoft Macbook Or Ipad (For Pc) Or Ipa (For Mac) (For Microsoft) (Programmer) (Or Mac) Or Macbook (For
Projet Java Responsables: Ocan Sankur, Guillaume Scerri (LSV, ENS Cachan) Objectives - Apprendre à programmer en Java - Travailler à plusieurs sur un gros projet qui a plusieurs aspects: graphisme, interface
Java Crash Course Part I
Java Crash Course Part I School of Business and Economics Institute of Information Systems HU-Berlin WS 2005 Sebastian Kolbe [email protected] Overview (Short) introduction to the environment Linux
Chapter One Introduction to Programming
Chapter One Introduction to Programming 1-1 Algorithm and Flowchart Algorithm is a step-by-step procedure for calculation. More precisely, algorithm is an effective method expressed as a finite list of
Class 16: Function Parameters and Polymorphism
Class 16: Function Parameters and Polymorphism SI 413 - Programming Languages and Implementation Dr. Daniel S. Roche United States Naval Academy Fall 2011 Roche (USNA) SI413 - Class 16 Fall 2011 1 / 15
Chapter 2 Introduction to Java programming
Chapter 2 Introduction to Java programming 1 Keywords boolean if interface class true char else package volatile false byte final switch while throws float private case return native void protected break
CSC230 Getting Starting in C. Tyler Bletsch
CSC230 Getting Starting in C Tyler Bletsch What is C? The language of UNIX Procedural language (no classes) Low-level access to memory Easy to map to machine language Not much run-time stuff needed Surprisingly
Konzepte objektorientierter Programmierung
Konzepte objektorientierter Programmierung Prof. Dr. Peter Müller Werner Dietl Software Component Technology Exercises 3: Some More OO Languages Wintersemester 04/05 Agenda for Today 2 Homework Finish
Object Oriented Software Design
Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 28, 2010 G. Lipari (Scuola Superiore Sant Anna) Introduction
Java in Education. Choosing appropriate tool for creating multimedia is the first step in multimedia design
Java in Education Introduction Choosing appropriate tool for creating multimedia is the first step in multimedia design and production. Various tools that are used by educators, designers and programmers
Polymorphism. Problems with switch statement. Solution - use virtual functions (polymorphism) Polymorphism
Polymorphism Problems with switch statement Programmer may forget to test all possible cases in a switch. Tracking this down can be time consuming and error prone Solution - use virtual functions (polymorphism)
Programmierpraktikum
Programmierpraktikum Claudius Gros, SS2012 Institut für theoretische Physik Goethe-University Frankfurt a.m. 1 of 21 10/16/2012 09:29 AM Java - A First Glance 2 of 21 10/16/2012 09:29 AM programming languages
Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)
Boolean Expressions, Conditions, Loops, and Enumerations Relational Operators == // true if two values are equivalent!= // true if two values are not equivalent < // true if left value is less than the
C++ Outline. cout << "Enter two integers: "; int x, y; cin >> x >> y; cout << "The sum is: " << x + y << \n ;
C++ Outline Notes taken from: - Drake, Caleb. EECS 370 Course Notes, University of Illinois Chicago, Spring 97. Chapters 9, 10, 11, 13.1 & 13.2 - Horstman, Cay S. Mastering Object-Oriented Design in C++.
Installing Java. Table of contents
Table of contents 1 Jargon...3 2 Introduction...4 3 How to install the JDK...4 3.1 Microsoft Windows 95... 4 3.1.1 Installing the JDK... 4 3.1.2 Setting the Path Variable...5 3.2 Microsoft Windows 98...
Curriculum Map. Discipline: Computer Science Course: C++
Curriculum Map Discipline: Computer Science Course: C++ August/September: How can computer programs make problem solving easier and more efficient? In what order does a computer execute the lines of code
