Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Learning Plan 6 Java Programming Intro to Object Oriented Programming Object Oriented Programming (OOP) • Up until this point, all of our programs contained one class (Furniture, Admissions, etc.) • For example: public class HelloWorld { public static void main(String[] args) { System.out.println(“HelloWorld”); } } public class HelloWorld { public static void main(String[] args) { System.out.println(“HelloWorld”); } } • Our programs contained one class • Each class (or each program) contained a main method • We are now going to start adding additional classes to our programs • Our programs will contain more than one class • Only one of the classes will contain a ‘main’ method …. The rest do not. Object Oriented Programming • We are going to explore the OOP concept • We’ve already been using it • OOP allows for reusability of code – Why reinvent the wheel? • Consider the following code: Object-Oriented Programming (OOP) JOptionPane.showInputDialog(null, “Enter Name”): • We’ve used this code frequently • There is a file called JOptionPane.java that has been written and compiled for us (it became JOptionPane.class) • Every time we wanted to ask the user for input, we REUSED the code from the JOptionPane class Object Oriented Programming • Start with Head First Java book • Might jump around slightly • Basic OOP Concepts and more advanced concepts – We will discuss & use basic concepts in depth – We will discuss and analyze advanced OOP concepts but use more of the concepts in other courses. OOP • Basic concepts include: – Classes, objects, methods, instance variables/properties, arguments, parameters, instantiation, encapsulation • Advanced Concepts: – Inheritance superclass/subclass, overriding methods, polymorphism, abstract classes, interfaces • Chapter 1 – read 2-3; 8-17 • Before you start – Page 2 talks about the Java Virtual Machine (JVM) Java is a “write once, run anywhere” programming language. – Allows programs to run on multiple devices – Page 3 shows you that to compile a program, you execute the ‘javac’ command and to run it you start the JVM and execute the ‘java’ command • Textpad does this automatically for us!!