Flow of the My FirstApplication Program MainWindow mainWindow; mainWindow new Mainwindow()i mainWindow. setvisible( true )i mainWindow MainWindow State-of-Memory Diagram C 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 2-6
© 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 2 - 6 Flow of the MyFirstApplication Program MainWindow mainWindow; mainWindow = new MainWindow(); mainWindow.setVisible( true ); mainWindow MainWindow State-of-Memory Diagram
Object Declaration Class Name This class must be defined Object Name before this declaration can One object is declared be stated here MainWindow mainWindow MO Account customer ore Examples Student Jan, jim, jon, Vehiclecar. car2 C 2000 McGraw-Hill troduction to Object-Oriented Programming with Java--Wu Chapter 2-7
© 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 2 - 7 More Examples Object Declaration Class Name This class must be defined before this declaration can be stated. Object Name One object is declared here. MainWindow mainWindow; Account customer; Student jan, jim, jon; Vehiclecar1, car2;
Object creation Object Name Class Name Argument Name of the objectve An instance of this class is No arguments are used are creating here created mainWindow new MainWindow More customer=new Customer() Examples Jon new Student( John Java) car new Vehicle(): C 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 2-8
© 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 2 - 8 Object Creation Class Name An instance of this class is created. Object Name Name of the object we are creating here. mainWindow = new MainWindow ( ) ; Argument No arguments are used here. More Examples customer = new Customer( ); jon = new Student(“John Java” ); car1 = new Vehicle( );
Distinction between declaration and creation Customer customer i customer new Cus tomer()i customer new Cus tomer( )i customer Created with the Created with the second first new Customer Customer new. Reference to the first Customer object is lost C 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 2-9
© 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 2 - 9 Distinction Between Declaration and Creation Customer customer; customer = new Customer( ); customer = new Customer( ); customer Customer Customer Created with the first new. Created with the second new. Reference to the first Customer object is lost
Sending a message object Name Name of the object to Method Name Argument which we are sending a The name of the message The argument we are message we are sending passing with the message mainWindow. setVisible( true) More account deposit( 200.0) Examples student setName(john) car l. startEngine() C 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 2-10
© 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 2 - 10 Sending a Message Method Name The name of the message we are sending. Object Name Name of the object to which we are sending a message. mainWindow . setVisible ( true ) ; Argument The argument we are passing with the message. More Examples account.deposit( 200.0 ); student.setName(“john”); car1.startEngine( );