INTRODUCTION TO JAVA Flashcards
Who created Java and when?
Creator: James Gosling
From: Sun Microsystems Inc
Year: 1995
Later Acquired BY: Oracle Corporation
a class-based, object-oriented programming language and is designed to have as few implementation dependencies as possible.
JAVA
Syntax of Java is similar to:
C/ C++
What is the meaning of the slogan WORA
Write Once Run Anywhere
Why is Java called Java?
Named after the island where the first coffee was produced, Java Coffee
ensures the same Java code can be run on different operating systems and platforms.
Java Virtual Machine
Reasons to use Java
- Easy to Learn
- Simple to use
- Open source / FREE
- Popular
- Similar syntax with C and C++
- Allows code to be reused, LOWERS Development COSTS
is required and you will see it in every Java
program:
Main Method
method to print a line of text to the screen.
Print Method
println();
All Java variables must
be identified with unique names
called:
Identifiers
Give me examples of primitive data type
byte
short
int
long
float
double
boolean
char
Give me examples of non primitive data type
String
Arrays
Classes
Interface
and more…
data types are called reference types because they refer to objects
Non primitive
These are used to perform common mathematical operations
Arithmetic Operators
These are used to assign values to variables
Assignment Operators
These are used to compare two values (or variables). The return value is true or false.
Comparison Operators
These are used to determine the logic between variables or values.
Logical Operators
These are used to perform operations on individual bits of the operands. They are useful for low-level
programming, such as manipulating bits in memory, encryption, compression, etc.
Bitwise Operators
This class is part of the java.util package in
Java and is used for reading input from different sources, such
as the keyboard.
java.util.Scanner;
Cannot be used for a variable name in java
Keywords (Reserved Words)
is an object associated with the standard
input device.
System.in object
Scanner method used to read a string value form the user is:
next()
There is also a short-hand if else, which is known as the _______ because it consists of three operands.
ternary
operator
loop inside another loop.
nested loop
is used exclusively to loop
through elements in an array.
for each loop
The simplest kind of loop in Java
while loop
can also be used to jump out of a loop.
Break Statement
breaks one iteration (in the loop), if a
specified condition occurs, and continues with the next iteration in the loop (parang “skip”).
The continue statement
are functions defined within classes
Methods
You can pass data, known as________, into a method.
parameters
are variables declared
within a class.
Global Variables
These are variables declared
inside a method, condition,
loops and any other block of
code.
Local Variables
You can use the same method name but
different parameters so that you will cater every possibility of a
method
Overloading methods
the technique of making a function call itself.
Recursion
To aid in the organization of large code repository, Java allows
a group of related type definitions (such as classes) to be
grouped into what is known as a
Packages
IMPORTING PACKAGES
What does importing specific packages look like
import packagename.classname
The process of creating an instance of a class so we can use it on
our program.
Class instantiation