a) A left bracket ( { ) begins the body of every method, and a right bracket ( } ) ends the
d) Blank lines, space characters, new line characters and are called white space are ignored by
compiler.
2. a
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package assignment1b;
/**
*
* @author Benjamin Talic
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
System.out.println("Hello World");
System.out.println("Welcome to Java");
System.out.println("In CS 201");
}
2.b package assignment1b;
/**
*
* @author Benjamin Talic
*/
public class Program2b {
3. package assignment1b;
/**
*
* @author Benjamin Talic
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
operation=a/b;
System.out.println("a/b="+operation);
operation=a*b;
System.out.println("a*b="+operation);
}
}
4. package assignment1b;
/**
*
* @author Benjamin Talic
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
//box
System.out.print("*********\n* *\n* *\n* *\n"
+ "* *\n* *\n* *\n* *\n"
+ "*********\n");
//oval
System.out.print(" *** \n * *\n* *\n* *\n"
+ "* *\n* *\n * *\n *** \n");
//arow
System.out.print(" * \n *** \n*****\n *\n *\n *\n *\n *\n *\n");
//diamond
System.out.print(" *\n * *\n * *\n * *\n * *\n * *\n *\n");
1. Edit
We write the program in some text editor or java compiler, correct mistakes
2. Compile
The java compiler translates the java program into bytecodes.
3. Load
In phase 3, the program must first be placed in memory before it can be executed. This is
done by the class loader.
4. Verify
Before the bytecodes in an application are executed by the java interpreter, they are
verified by the bytecode verifier.
5. Execute
the computer, under the control of its CPU, interprets the program one
bytecode at a time. Thus performing the actions specified by the program.
5.
1. structured programming
2. procedure oriented programming
3.object oriented programming