Professional Documents
Culture Documents
27 reflections
Class powerpoint can be found on ilearn… and I followed through the installation of Java SE and
then installation of netbeans with all packages. It shows the steps through opening project, build
and run, set breakpoint and add watch list. Instead of Idx in my version it uses wordIdx instead.
Then I went through GitHub tutorial… create master and edit-readme branch, made some
changes and commit, create pull request and then merge pull request where it has options of
create a merge all commit, squash and merge 1 commit, or rebase and merge 1 commit. The
result looks like the following:
Each object has its role and contains its information. Information hiding is achieved by knowing
what the object’s role is without knowing the details of the implementation.
Client passes messages to the server providing the service with its methods of computation.
Messages contain receiver destination of server and associated information to be processed by
server.
The role and service of the server can be described in a class, and each server object can be
instantiated with that class capable to performing computation of tasks from the messages
received.
Within class hierarchy, higher level class (superclasses) in general shared its role and
information with its lower level class (subclasses). We sometimes get to look into higher class in
hierarchy for instances function, and never create an instance from the more-generalized classes
in higher hierarchy, or abstract classes as no place to hold its functions.
Java comes from C++ and smalltalk, is web-based portable system in distributed programming
heterogeneous architecture. It doesn’t have multiple inheritance like C++, is object-oriented, is
network-savvied such as URLs and sockets, and is robust with exception handling and garbage
collection. It has its own VM and is portable on various architecture with fixed machine-
dependent details. It is multithreaded with parallel execution and client-server computing,
dynamic with pluggable code and classes.
JVM is a program specification which interprets by scanning byte codes and performing
indicated operations on virtual machine. Therefore instances can execute same byte code on
various machine environment. Java programs are allowed only in sandboxes where the VM
won’t allow codes to access/modify client’s files.
Github: Hello.java
public class Hello { //one public class per file, class name as file name
public static void main ( String args[] ) { //array of String
If ( args.length > 0 ) { //a property of the array object accessing by .length
System.out.println( “Hello “ + arg[0] ); //+ to concatenate Strings
} else {
System.out.println( “Hello everybody!” ); //print followed by a return
}
}
}
Compiling:
javac Hello.java
Results in Hello.class file with byte codes
Executing:
Java Hello
Hello everybody!
public B( int j ) { //no default constructor is provided: always instantiate B with an int arg
i = j;
}
void p() {
System.out.println( i );
}
}
B b = new B( 5 );
aa.incI( b ); // setting i in the same object
a.incI( b ); // setting i in the same object
class B {
private int I = 0;
B( int I ) {
This.i = I;
}
Output
java ReferenceSemantics
a’s I is 7
aa’s I is 7
aa a i: 0 6 7
b i: 5 6 7
Exception Handling
try {
<statements that may throw exception>
} catch ( ExceptionType exceptionOne ) {
<statements to handle exception>
}
….
} catch ( ExceptionType exception ) {
<statements to handle exception>
} finally {
<statements that will always be executed, with or without exception>
}
/* exception without catching */
public class ExceptionTestOne {
static int number[] = { 0, -2, 5, 27, 3};
java ExceptionTestOne
Exception in thread “main”
java.lang.ArrayIndexOutOfBoundsException: 5
at ExceptionTestOne.main(ExceptionTestOne.java:8)
/* catching exception */
public class ExceptionTestTwo {
static int number[] = { 0, -2, 5, 27, 3};
try {
for ( int I = 0; I <= 5; i++ ) {
sum += numbers[ i ];
}
} catch ( ArrayIndexOutOfBoundsException e ) {
System.out.println( “*** Array index out of bounds” );
}
java ExceptionTestTwo
*** Array index out of bounds
sum: 33