Java Cis Assignment 1

Topics: Compiler, C, Computer program Pages: 5 (674 words) Published: January 13, 2013
Java CIS 109 Assignment 1

A. Programming theory
1. Basic Ideas

1(a) Delimiters are used as comments. The Phrase is put in there to be shown to the user whilst programming, but is not shown when the program is to run. Those delimeters indicate comments, the compiler ignores what is inside.

1(b) “import*;” means that the complier will check what libraries are necessary to compile the program, and it will simply import them. In this case, the program would not be able to run without the “import*”, because the compiler will not find the “System.out.println” method

1(c) The asterisk (*) after io will be able to provide access to all the classes under the package.

1(d) Class files are the result of a compiled .java file. An object is an instance of a class, created with the "new" keyword.

1(e) Public means that all methods in a package have access to the method.

1(f) The "main" method needs to be declared public static in order to compile.

1(g) Void means that the method does not return any value.

1(h) Main is a keyword that tells jave to begin program execution at that point.

1(i) The semi-colon is a statement terminator. This is needed in java for program statements.

1(j) Main is the name of the method but, the System.out.println() is a call to the* method println for displaying the words "Hello World"

2. Data Types

Whole (counting) numbers:
Name Bytes of Storage taken up Range Example 2.1 int 4 -2,147,483,648 to +2,147,483,647 42
 2.2 short 2 -32768 to 32767 66 
2.3 byte 1 -128 to 127 100 
2.4 long 8 -9223372036854775808 to 9223372036854775807 48933

Fractions (decimal numbers)
Name Bytes of Storage taken up Number of significant digits Example 2.5 double 8 15 to 17 37.26 2.6 float 4 7 26.77 Single Characters

Name Bytes of Storage taken up Example 2.7 char 1 c 'Logical outcomes': true or false
Name Bytes of Storage taken up Example 2.8 boolean 1 true

3. Variables
3.1 A variable is something that can store data, such as numbers and words. One of the common types of variables is called "int", which can store numbers. 3.2 In order to do so, first give the data a type, depending on what value it is, then declare it. Example “int I = 4;”. The computer now knows that I = 4. 3.3 There will be an error whilst compiling the program.

3.4 (d) Since there is a space in-between the two words.

4. Operators
Operator| Use|
+| Op1+Op2 |
-| Op1-Op2|
*| Op1*Op2|
/| Op1/Op2|
%| Op1%Op2|

4.2 int I = (y+z);
Operator| Use|
<| Op1<Op2|
<=| Op1=<Op2|
>| Op1>Op2|
>=| Op1>=Op2|
==| Op1==Op2|
!=| Op1!=Op2|


Operators| Use|
True| System.out.println( true || false && false); //true| False| System.out.println( true && false || false); //false| 4.4

5. Control Structures
5.1 Making Choices

5.1.1 kbReader = new Scanner(;
System.out.print(“What is your grade? ”);

int myGrade = kbReader.nextInt( );
if (myGrade >= 70)
 System.out.println(“Congratulations, you passed.”); }
else {
System.out.println(“Better luck next time.”);
5.1.2 char key;

printf("Enter an arithmetic operator\n");...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • CIS 348 ASSIGNMENT 1 Essay
  • Java Essay
  • JAVA Essay
  • Assignment 1 Becoming an effective Leader Essay
  • Essay about CIS 517 Assignment 1
  • Homework CH 1 Java Essay
  • CIS 515 Assignment 3 Essay
  • Cis 210 Assignment 1 Essay

Become a StudyMode Member

Sign Up - It's Free