CS 178: Programming with Multimedia Objects Aditya P. Mathur Professor of Computer Sciences Purdue University, West Lafayette August 27, 2004 Last update: August 30, 2004 Classes, Objects, Applets
Course Introduction Aditya P. Mathur Learning Objectives What is an object? What is a class? Class hierarchy Simple example (Applet)
Course Introduction Aditya P. Mathur Class A collection of data and methods. Data: Example: class Dog dogName dog Breed dogOwner dogVet
Course Introduction Aditya P. Mathur High Level-Low Level Languages A CPU|GPU|SPU in a computer understands instructions coded as only 1’s and 0’s. The language of 0’s and 1’s is a low level language known as machine language. Java allows the coding of instructions using keywords from English, e.g. applet, class, and String. Java is a high-level language. How does a CPU/GPU/SPU understand instructions coded in Java?
Course Introduction Aditya P. Mathur Language Translation Java Program Java Compiler Byte Code Java Virtual machine (JVM) Instructions executed by the CPU Output JVM interprets Java byte code instructions. JVM instructions are executed by the CPU. Different from machine (CPU) code
Course Introduction Aditya P. Mathur Platform Independence Byte Code Java Virtual machine Java Virtual machine Java Virtual machine WindowsUnixOS X Others
Course Introduction Aditya P. Mathur Structure of a Java Program Java Program Class One or more classes Method Each class contains data and methods. Data Method Data Method Data Instructions
Course Introduction Aditya P. Mathur A Sample Java Applet Let us examine an interesting Java applet!
Course Introduction Aditya P. Mathur Do you know what these mean? literal identifier method parameters class object type integer (int) void arguments Button new Graphics init paint setColor event ActionListener actionPerformed start