Final - 1 Chapter 1: Primary Storage: RAM: fast, expensive,...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 1: Primary Storage: RAM: fast, expensive, loses data when power is turned off Secondary storage: hard disk: ROM: cheaper, no loss of data when power is off Machine instructions are encoded as numbers. Virtual machine decodes them and performs tasks. Compiler translates high level language to machine instructions. High-level language allows us to describe tasks at a higher conceptual level than machine code. Java: To write internet applets, is safe and portable, has huge library packages. Java is case sensitive, has free-form layout. Classes are the fundamental building blocks of Java programs. A java program contains a class with a method main which contains instructions to perform a task. Static indicates that main method does not operate on an object. Main must be static since it starts running before the program can create objects. Each statement ends with a semi-colon (;); The console window is represented by the object out which is placed in the system class. println() is the name of the method. Class.object.method A method is called by specifying the object, the method name, and method parameters. A string is a sequence of characters enclosed in quotation marks. Java compiler translates source code into byte code i.e., class files that contain instructions for Java virtual m/c. The Java virtual m/c translates byte code into m/c language, i.e., loads program instructions from class files and library files. Chapter 2 : Classes describe the behavior of objects. For input: Scanner in = new Scanner (System.in); int quantity = in.nextInt(); nextDouble(), nextLine() to read a line i.e., multiple words, next() to read a single word. Insert import java.util.Scanner; or import java.util.*; line in starting of the program. System.out has the type PrintStream. Every value in Java has a type. Identifiers are names of variables, classes, or methods: can be letters, digits, $ and _. No spaces or reserved words allowed. You can’t start with a number. Identifiers are case sensitive. Variable and method names should start with lowercase. Class names should start with uppercase according to conventions, but it won’t cause an error if you don’t follow this rule. All variables should be declared and initialized before accessing them. Objects are entities in program that one manipulates by calling methods. Method is sequence of instructions that accesses the data of an object. A class specifies the methods you can apply to its objects. “Hello” object belongs to the String class. length and toUpperCase are methods in the string class which can be applied to the object. System.out object belongs to the PrintStream class. println is a method in the PrintStream class. Parameter is an input to a method.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/17/2012 for the course ECE 203 taught by Professor Robincarr during the Fall '07 term at Drexel.

Page1 / 7

Final - 1 Chapter 1: Primary Storage: RAM: fast, expensive,...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online