Download presentation
Presentation is loading. Please wait.
1
Introduction to By Mati Yanko
2
Primary Goals of Java Portable Secured Object Oriented
3
Portable – Platform Independent
5
Secured ByteCode instructions Download through Network Verify Code Run it Network
6
Object Oriented Programming Encapsulation Inheritance Polymorphism
7
Object Oriented Programming What is an Object ? Variables (state) Methods (behavior)
8
static int* buffer; static int counter; void initStack() { buffer = (int*)malloc( sizeof(int) * 10); counter=0; } void freeStack() { free(buffer); } int pop() { return buffer[-- counter]; } void push(int number) { buffer [counter ++]=number; } int main() { initStack(); push(3); pop(); freeStack(); }
9
public class Stack { private int buffer []; private int counter; Stack() { buffer = new int[10]; counter=0; } void printStack { … } int getCounter() { return counter;} void push (int number) { buffer[counter++] =number; } int pop() { return buffer[ - - counter]; } } Data members (state) Methods (behaviour)
10
public void main() { Stack myStack=new Stack(); // memory allocation myStack.push(3); myStack.pop(); mystack.pop();// oops }
11
Object Oriented Programming What is Inheritance ? Stack Stack with Buffer underflow check
12
public class betterStack extends Stack { int pop() { if (getCounter() >= 0) return super.pop();// superclass method } public void main() { betterStack myStack=new betterStack(); myStack.push(3); myStack.pop(); mystack.pop();// ok }
13
Object Oriented Programming What is Polymorphism ? Public void main() { Stack myStack;// myStack is null betterStack newStack=new betterStack(); myStack = newStack; myStack.pop() ; // ??? }
14
C vs. Java Macros Low-level memory management Pointer arithmetic p++ Casts Free Unsafe arrays Stack allocation Big and small values Object Oriented Dynamic class loading References instead of arbitrary pointers Heap only No free (Garbage collection) Exceptions
15
References Java programming Language / SUN http://java.sun.com
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.