LETU COSC 2103 - Introduction to Java

Unformatted text preview:

Introduction to JavaA Brief History of OOP and JavaSlide 3Slide 4Slide 5Slide 6Phases of Java ProgramsSlide 8Slide 9Programming with "Ready to Program"Slide 11Java ProgramsCreating a Java ApplicationSlide 14Slide 15Slide 16Slide 17Slide 18Introduction to Java Application ProgramsSlide 20Java programJava programClass DeclarationClass MembersSlide 25DeclarationsCalling an Object MethodJava ProgramSlide 29A Simple Program: Printing a Line of TextSlide 31Slide 32Slide 33Sample ProgramSlide 35Another Java Application: Adding IntegersSlide 37Slide 38Values Held by VariablesVariable Declaration SyntaxConstantsPrimitive TypesReference TypesJava Provided Reference TypesCreating Reference Type Values: ConstructorsDefault Value: nullConstructing an ObjectReady to Program I/O ClassesStdinStdoutSlide 51Sample ProblemProgram TasksIntroduction to Java2A Brief History of OOP and Java•Early high level languages–_________________________•More recent languages–BASIC, Pascal, C, Ada, Smalltalk, C++, Java•______________ operating system upgrades prompted the development of the C language•Powerful language … but not the best intro to programming–Difficult for ________________________–Does not fit modern programming strategies3A Brief History of OOP and Java•Simula-67 was a language which facilitated the modeling of real-world objects–New language feature called the “_________”–A class was ______________ through “inheritance”•This was the foundation needed for Object Oriented Programming, OOP•Smalltalk-80 used this concept–This is the first truly object-oriented language4A Brief History of OOP and Java•The C language was extended to include “classes” and in 1983 became _________•The Java language originally conceived to control __________________________ using the OOP concept–Thus, was meant to be platform (or ____________) independent•Soon this was seen as well suited for running small programs (_____________) on Internet web pages–By 1995, Netscape browsers began supporting Java applets–This did much to establish Java as a major language5A Brief History of OOP and Java•Note typical implementation of a program on different platformsSource programCompiler for UNIX platformCompiler for Windows PlatformCompiler for Mac OS PlatformExecutable code for UNIX platformExecutable code for Windows platformExecutable code for Mac OS platformWe need ______________________________6A Brief History of OOP and Java•Contrast compiler with interpreter–Compiler runs ________________, translates to machine code for commands of whole program–_______________ translates one command at a time•Java combines these two–Java compiler generates intermediate “___________”–An ____________________ is developed for each platform to interpret the bytecode –Interpreter called the Java Virtual Machine or JVM7Phases of Java Programs1. Edit the source code–filename._____________2. Compile the source code into bytecodes–filename.__________3. Load the .class file into memory–applications: stored and executed from user's own computer–________________: loaded from a computer somewhere into a browser, executed by the browser8Phases of Java Programs4. Verify bytecodes–check for ___________ and potential security restrictions5. Computer interprets bytecodes–___________ bytecode at a time9Program is created in the editor and stored on disk.Compiler creates bytecodes and stores them on disk.Class loader puts bytecodes in memory.Bytecode verifier confirms that all bytecodes are valid and do not violate Java’s security restrictions.Interpreter reads bytecodes and translates them into a language that the computer can understand, possibly storing data values as the program executes.Phase 1Phase 2Phase 3Phase 4Phase 5DiskEditorCompilerClass LoaderDiskDiskPrimaryMemory......PrimaryMemory......PrimaryMemory......Bytecode VerifierInterpreter10Programming with "Ready to Program"•Find the "Ready" option on the program menu or click on the"_________" icon11Programming with "Ready to Program"•An empty ___________ window appears12Java Programs•A Java program consists of one or more classesThe name of the file and the name of the ________ must, have the same nameClasses consist of a collection of • • A Java class with a method called main() is a Java __________.13Creating a Java Application•The "Ready" environment will give you skeleton or boilerplate format for programs•Click on File, New, and HSA Console option•A dialog box asksfor the ________ of the class14Creating a Java Application•The appropriate boilerplate text appears in the edit window – note the color codingBold Face Java _______Black Identifiers in Java _________ libraryBlue___________ in your program____________CommentsRedQuoted Strings15Creating a Java Application•Fill in the necessary commands•Save theprogramNote that a dialog box will ask you for the nameBe sure to give it exactly the __________________16Creating a Java Application•To run a Java program–Press the button or–Press Ctrl+R or–Press F1•The consoleprogram showsa ___________window17Creating a Java Application•Make sure to ________________ the program before quitting–The "Ready" environment will remind you•To exit the "Ready" environment–Click the X close or–Choose File, Exit or–Use Ctrl-Q18Creating a Java Application•Errors in the program–Syntax errors are found for you by the compilerDialog box shows how many errors_________ line(s) highlighted_______________ of error given in the status bar19Introduction to Java Application Programs•Java is an ____________ oriented programming language–Uses objects to carry out the tasks–Sends to the objects to perform the tasks–Objects interact with each other to do the tasks–An actual object is called an ____________of a class•The class is the declaration of or blueprint for the object20Introduction to Java Application Programs•Object oriented programs:–A collection of object interactions that solve a problem•Note the similarity of this definition to the definition for a program// Welcome1.java// A first program in Javaimport hsa.*;public class Welcome1 { public static void main (String args[]) { Stdout.println("Welcome to Java Programming"); } // end method main} // end class Welcome1// Welcome1.java// A first program in Javaimport hsa.*;public class Welcome1 { public static void main (String args[]) {


View Full Document

LETU COSC 2103 - Introduction to Java

Documents in this Course
Arrays

Arrays

16 pages

Templates

Templates

17 pages

Methods

Methods

22 pages

Methods

Methods

22 pages

Arrays

Arrays

11 pages

Load more
Download Introduction to Java
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Introduction to Java and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Introduction to Java 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?