

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An example of a java program consisting of two classes, zookeeper and panda, created as part of a cs121/is223 course. The zookeeper class serves as the entry point, instantiating and running the panda class. The document also discusses the process of editing, compiling, and running a java program using an editor, compiler, and java virtual machine (jvm).
Typology: Study notes
1 / 2
This page cannot be seen from the preview
Don't miss anything!


ZooKeeper Example with Two Classes The following two classes make up a project called Zoo. The first class is the one where execution begins. Execution begins with its main method. That method instantiates the second class, Panda. It then runs the instance of the Panda class. /*
Editing, compiling and running a program The editor is used to create the .java file. The compiler then translates the Java programming language into Java bytecode. This is an intermediate code that can be run on a number of computers. The Java Virtual Machine (JVM) executes the program. Errors can occur both in compiling and running. The compiler checks for syntax errors. But there still may be run-time errors. These you have to find yourself when the program is run on the JVM. Syntax errors are errors in grammar, using the language. Run-time errors are errors in semantics, what the programmer intended. They are usually much harder to find. Syntax errors are things like missing semicolons. Run-time errors can be incorrect computations or errors in logic. They are often called bugs. You usually have to work on the after a break. Otherwise you can get stuck and not see where you have made a mistake. The following diagram shows the process. eclipse editor ZooKeeper.java Panda.java Java Compiler javac ZooKeeper.class Panda.class Output to screen