

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!


CS 110: Introduction to Computer Science Spring 2008
Having said that, let's discuss some of the basic differences between Java and Python...
Python is interpreted, meaning you compile and run program in one step: python prog.py Java has two phases. First, you compile the source code into byte code. Then you ‘run’ the java byte code. java
javac Prog.java java Prog
With Java, all code is written within a class. Each file has one class defined in it, and the file name must be the same as the class name (with .java appended) All methods are defined subordinate to a class. All variables are defined subord globals!) inate to a class or method (no evil
With Java, you must declare the type of everything: parameters, locals, and return values.
CS 110: Introduction to Computer Science Spring 2008
Take a look at the provided Coordinate programs in Java and Python:
http://www.cs.usfca.edu/~wolber/courses/110.f07/javaSamples/C oordinate.java
http://www.cs.usfca.edu/~wolber/courses/110.f07/python/coord.p y How are the two languages different? In particular, answer the questions on the next page:
constructors (one with no parameters and one with two), and a method ‘older’ which returns true if the object itself is older than the person sent in as a parameter. class, create two persons with data, call older, and print out a result In the main program for the statement.