















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
















CS031 Lecture 18 (^) Page 1
Pascal Van Hentenryck Objects
public class person { public char name[11]; public int age; public boolean employed; public int net_worth; }
.data name = 0 age = 12 empl = 16 # take a word worth = 20 psize = 24 pnum = 10 people: .word 240
.data psize = 24 n = 10 people: .byte 240 .text #initialize all of the records la $s0,people li $s1,n loop: jal init_person add $s0,$s0,psize sub $s1,$s1, bnez $s1,loop
What your JAVA Teachers Didn’t Tell You
class Animal { void eat(); void sleep(); } class Dog extends Animal { void eat(); void bark(); } class Cat extends Animal { void sleep(); void meow(); } How to compile a method typicalDay(Animal l) { l.eat(); l.sleep(); l.eat(); l.sleep(); … }
(dog) (ani) (cat) (ani)
class Animal { void eat(); } interface Mammal { void sleep(); void eat(); } class Dog extends Animal implements Mammal { void eat(); void sleep(); void bark(); }
bark.co
Linked Lists in Assembly
// _head is the head of the list; List search(int x) { List t0 = _head; while (t0 != null) { if (t0.getKey() == x) return t0; else t0 = t0.getNext(); } return null; }