0% found this document useful (0 votes)
29 views4 pages

Overview of Java Programming Basics

Uploaded by

cyronejoynes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views4 pages

Overview of Java Programming Basics

Uploaded by

cyronejoynes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JAVA FUNDAMENTAL CONCEPTS

1. developed in early 1990s by James Gosling et. al. 1. Java programs are made up of one or more classes.
2. Green Project at Sun Microsystems 2. A Java class is defined through a class declaration,
3. originally named Oak and intended for programming 3. Java class names start with an uppercase letter. Java
networked “smart” consumer electronics programs are case-sensitive.
4. launched in 1995 as a “programming language for the 4. A Java source code file usually contains one class
Internet” declaration, but two or more classes can be declared
5. quickly gained popularity with the success of the in one source code file. The file is named after the
World Wide Web class it declares, and uses a .java filename extension.
6. currently used by around 5 million software 5. For a class to be executable, it must be declared
developers and powers more than 2.5 billion devices public, and must provide a public static method called
7. Design Goals main, with an array argument of type String.
o simple: derived from C/C++, but easier to learn 6. If a file contains more than one class declaration, only
o secure: built-in support for compile-time and one of the classes can be declared public, and the file
run-time security must be named after the sole public class.
o distributed: built to run over networks o 7. The Java compiler (javac) is used to compile a Java
object-oriented: built with OO features from the start source code file into a class file in bytecode format.
o robust: featured memory management, exception The resulting class file has the same name as the
handling, etc. source code file, but with a .class filename extension.
o portable: “write once, run anywhere'' 8. The Java Virtual Machine (java) is used to execute the
o interpreted: “bytecodes” executed by the Java class file
Virtual Machine
o multithreaded, dynamic, high-performance, JAVA STATEMENT
architecture-neutral - A statement is any complete sentence that causes
o Bytecodes are the machine language understood by some action to occur. A valid Java statement must end
the Java virtual machine with a semicolon.
JAVA BLOCKS
Java Virtual Machine or JVM - A block is one or more statements bounded by an
1. a virtual machine, usually implemented as a program, opening and closing curly braces that groups the
which interprets the bytecodes produced by the Java statements as one unit. Block statements can be
compiler nested indefinitely. Any amount of white space is
2. the JVM converts the bytecodes instructions to allowed.
equivalent machine language code of the underlying JAVA EXPRESSIONS
hardware; compiled Java programs can be executed on - An expression is a value, a variable, a method, or one
any device that has a JVM of their combinations that can be evaluated to a value.
JAVA IDENTIFIERS
Java Programming Environment - Identifiers are tokens that represent names of
1. Java programming language specification variables, methods, classes, etc. Examples of
o Syntax of Java programs identifiers are: Hello, main, System, out.
o Defines different constructs and their semantics - Java identifiers are case-sensitive. This means that the
2. Java byte code: Intermediate representation for Java identifier: Hello is not the same as hello
programs PRIMITIVE DATA TYPES
3. Java compiler: Transform Java programs into Java byte ● four of them represent integers: byte, short, int, long
code ● two of them represent floating point numbers: float, double
4. Java interpreter: Read programs written in Java byte ● one of them represents characters: char
code and execute them - a char variable stores a single character
5. Java virtual machine: Runtime system that provides - character literals are delimited by single quotes:
various services to running programs ● and one of them represents boolean values: boolean
6. Java programming environment: Set of libraries that - a boolean value represents a true or false condition
provide services such as GUI, data structures, etc. the reserved words true and false are the only valid
7. Java enabled browsers: Browsers that include a JVM + values for a boolean type
ability to load programs from remote hosts
SEPARATORS LOGICAL OPERATORS
- symbols that indicate the division and arrangement of
groups of code. The structure and function of code is
generally defined by the separators.
1. parentheses ( ) - Used to define precedence in
expressions, to enclose parameters in method
definitions, and enclosing cast types
2. braces { } - Used to define a block of code and to hold
the values of arrays.
3. brackets [ ] - Used to declare array types.
4. semicolon ; - Used to separate statements.
5. comma , - Used to separate identifiers in a variable FLOWCHART
declaration and in the for statement.
6. period . - Used to separate package names from
classes and subclasses and to separate a variable or a
method from a reference variable.

VARIABLES
1. a variable is a name for a location in memory
2. a variable must be declared by specifying the
variable's name and the type of information that it will
hold.
3. multiple variables can be created in one

VARIABLE INITIALIZATION
1. assigning a value to a variable for the first time
2. a variable can be given an initial value in the
declaration with an equal sign
DEBUGGING
ESCAPE SEQUENCE - Most of the time, after a programmer has written the
program, the program isn’t 100% working right away.
The programmer has to add some fixes to the program
in case of errors (also called bugs) that occurs in the
program. This process is called debugging.

2 TYPES OF PROGRAM ERROR


1. Compile-Time Error
- Occur if there is a syntax error in the code.
The compiler will detect the error and the
INCREMENT OPERATOR (++) program won’t even compile. At this point, the
- increases the value of a variable by 1 programmer is unable to form an executable
DECREMENT OPERATOR(--) that a user can run until errors are fixed.
- decreases the value of a variable by 1 Forgetting a semi-colon at the end of a
RELATIONAL OPERATORS statement or misspelling a certain command,
for example, is a compile-time error.
2. Runtime Error
- Compilers aren’t perfect and so can’t catch all
errors at compile time. This is especially true
for logic errors such as infinite loops. This type
of error is called runtime error. For example,
the actual syntax of the code looks okay. But
when you follow the code’s logic, the same
piece of code keeps executing over and over
again infinitely so that it loops.
}
import [Link]; //create an if-else statement that
Scanner kbd = new Scanner([Link]); satisfies condition for y
if(valuey>valuex &&
[Link]("Enter a number: "); valuey>valuez){
int num = [Link](); [Link]("The Highest
int sum = num1+num2; Number is " + valuey);
[Link]("The sum is "+sum); } else if (valuey>valuex &&
valuey<valuez){
[Link]("The Median
Median is " + valuey);
} else if (valuey<valuex &&
valuey>valuez){
[Link]("The Median
Number is " + valuey);
} else if (valuey<valuex &&
valuey<valuez){
[Link]("The Lowest
Number is " + valuey);
}
//create an if-else statement that satisfies
condition for z
if(valuez>valuex &&
valuez>valuey){
[Link]("The Highest
Number is " + valuez);
} else if (valuez>valuex &&
valuez<valuey){
[Link]("Enter number of hours: "); [Link]("The Median
int hours = [Link](); Median is " + valuez);
if(hours<=4){ } else if (valuez<valuex &&
int less = 35; valuez>valuey){
[Link]("Parking Fee:P" + less); [Link]("The Median
}else if(4<hours && hours<=18){ Number is " + valuez);
int mid = 35 + (15*(hours-4)); } else if (valuez<valuex &&
[Link]("Parking Fee:P" + mid); valuez<valuey){
}else if(hours>18){ [Link]("The Lowest
int max = 250; Number is " + valuez);
[Link]("Parking Fee:P" + max); }
//create an if-else statement that satisfies
condition for ascending order
[Link]("Enter x: ");
if(valuex>valuey && valuex>valuez
int valuex = [Link]();
&& valuey>valuez){
[Link]("Enter y: ");
[Link]("Ascending
int valuey = [Link]();
order is " + valuez + valuey + valuex);
//prompt a message to get an input for z
} else if(valuex>valuey &&
[Link]("Enter z: ");
valuex>valuez && valuez>valuey){
int valuez = [Link]();
[Link]("Ascending
//create an if-else statement that satisfies
Order is " + valuey + valuez + valuex);
condition for x
} else if(valuey>valuex &&
if(valuex>valuey && valuex>valuez){
valuey>valuez && valuex>valuez){
[Link]("The Highest
[Link]("Ascending
Number is " + valuex);
order is " + valuez + valuex + valuex);
} else if (valuex>valuey &&
} else if(valuey>valuez &&
valuex<valuez){
valuey>valuex && valuez>valuex){
[Link]("The Median
[Link]("Ascending
Median is " + valuex);
Order is " + valuex + valuez + valuey);
} else if (valuex<valuey &&
} else if (valuez>valuex &&
valuex>valuez){
valuez>valuey && valuex>valuey){
[Link]("The Median
[Link]("Ascending
Number is " + valuex);
Order is " + valuey + valuex + valuez);
} else if (valuex<valuey &&
} else
valuex<valuez){
[Link]("Ascending
[Link]("The Lowest
Order is " + valuex + valuey + valuez);
Number is " + valuex);
if-else
switch
loop
while loop
do while loop
one dimensional
two dimensional

You might also like