Intro to Java Flashcards
What is Java?
Java is a full-featured, general-purpose object-oriented programming language that can be used to develop robust mission-critical applications
Who developed Java and where?
Java was started as a project called “Oak” by James Gosling in June 1991 at Sun Microsystems
Why was there a need for platform-independent language?
Consumer electronic devices such as televisions, washing machines, microwaves, and other similar electronic devices used different platforms; therefore, there was a need for platform-independent language, such as Java
What does the term platform refer to?
The term platform refers to a specific combination of hardware and system software (operating system)
Define platform independence
The capability of a computer program to run on multiple platforms is referred to as platform independence
When was Java formally released?
In 1995 - Oak was renamed Java
When did Oracle acquire Sun Microsystems?
2010
Name the two types of Java programs
- Stand-alone applications
2. Internet applets
What is a stand-alone java program?
It refers to a Java program that can run independently on a computer
Give an example of a stand-alone java program
Acrobat PDF Reader
What can stand-alone java programs be based on?
They can either be console-based or with a Graphical User Interface (GUI)
What does a Console-based Java application use?
Uses a text-only interface
What does a GUI-based Java application use?
Uses a graphical interface, such as command buttons, text fields, and a mouse
What are Java applets?
The Java programs that run in a web browser are called Java applets.
What are applets used for?
Applets are capable of performing many tasks on a web page, such as displaying graphics, playing sounds, and accepting user input. Applets are also used to create animation and interactive games.
How can applets be transported?
They can be transported over the internet from one computer to another through a Java-enabled browser or an applet viewer
What is machine language?
Computers were developed to carry out instructions that were written in their native language called machine language
What is machine code?
Machine language instructions are expressed as binary numbers called machine code
What is a binary no. made up of?
Just two digits - zero (0) and one (1)
What is each digit in a binary no. called?
Each digit, zero or one, is called a bit
A machine language instruction is just a sequence of _ and _
zeros and ones
Why does the machine code of one type of computer differ from another?
Different computers use different sets of binary codes for each instruction
When can a computer directly execute a program?
Only when the program is written in the computer’s machine language
State the issues with programming in machine language
It was a tedious process and was prone to errors. In addition to this, these programs were very difficult to read and modify
Why were assembly languages developed?
To overcome the issues with programming in machine language - it was a tedious process and was prone to errors. In addition to this, these programs were very difficult to read and modify.
What were assembly languages?
These allow programs to be written using symbolic operations called mnemonic codes
What mnemonic code can you use for 100101?
ADD
What was the issue with assembly languages and what was its solution?
Although assembly languages were easier to write than machine languages, they were not recognized by the computer. Therefore, another program known as an assembler was needed to translate programs written in assembly language into machine language
What is an assembler?
An assembler is a program that translates an assembly language program into machine code
When did high-level programming languages emerge? What were they?
In the 1950s. A high-level language is quite similar to the English language and is easy to learn and use
What is a source code or source program?
A program written in a high-level programming language is called a source program
What is an interpreter?
An interpreter is a program that translates the source code instructions into machine code line-by-line.
How does the interpreter work?
It runs in a loop, reading the next statement from the source code and translating it into the necessary machine code.
What is a compiler?
A compiler is a program that translates code written in a high-level language into machine code all at once before the program is executed
What is the object code?
The object code is the machine language version of the source code
What is the difference between the execution of an interpreter and a compiler?
The execution of an interpreted program is slow, whereas the execution of a compiled program is fast
What happens in the traditional compilation process?
The object code generated by the compilation process is specific to the program you are compiling on. An equivalent machine code is generated for a particular platform. The compiler for one high-level language is different from another.
What happens in the Java compilation process?
The source code written in Java language is compiled into a machine code. The machine code is for a virtual machine known as Java Virtual Machine or JVM. The machine code for JVM is called Bytecode. This Bytecode needs a Java interpreter to convert it into the machine code of the computer on which it is to be executed.
What is the extension for the Java source code file?
.java
What is the extension for the Bytecode file?
.class
What is the role of executable code in computing?
In computing, executable code or an executable file causes a computer to “perform a series of instructions when it is opened”.
What is a JIT compiler?
A Just-In-Time compiler is a part of JVM that compiles selected portions of Bytecode into executable code
What is JRE?
JRE is an acronym for Java Runtime Environment. The JVM, along with many other class libraries, constitutes the JRE.
Name the features of Java
- Object-Oriented
- Robust
- Platform Independent
- Simple
- Secure
- Multithreaded
Why is JAVA an OOP language?
Because it treats everything as an object. The entire program code and data reside within objects and classes. This enables us to easily use and extend the object model
Why is Java a robust and reliable programming language?
It has a strict compile time and runtime checking for data types. Memory allocation and de-allocation is automatic in Java, so there is less for the programmer to worry about
How is Java platform independent?
The concept of “Write once, run anywhere” is one of the most important features of Java. Java applications can run on any platform that has the corresponding JVM installed on it.
What has simplified Java’s understanding and implementation?
The removal of many unreliable features of C and C++ (its predecessors)
How is Java secure?
Java allows applets to confine to the java runtime environment only. Applets cannot access any part of the computer when downloaded on the web browser. This helps to eliminate any damage due to malicious software and viruses.
Why is Java considered a robust and reliable programming language?
It has strict compile time and runtime checking for data types. Memory allocation and de-allocation is automatic in Java, so there is less for the programmer to worry about.
Why is Java considered a multithreaded programming language?
You do not need to wait for an application to finish one task before starting another. Multithreading works in a similar way as multiple processes run on one computer.
What is BlueJ?
BlueJ is an Integrated Development Environment (IDE) specifically designed for teaching Java at an introductory level.
What does the GUI provided by BlueJ contain?
- Code Editor - to write the program code
- Java Compiler - to compile your code
- Virtual Machine - to execute the java program
- Terminal - to view the output
- Debugger - to find problems in the code
What is the keyword public?
It is an access specifier that defines the scope of the class
What does the keyword class denote?
That this is the class with the name ‘whatever’
What is void?
Void is a keyword which signifies that this method will not return a value
What do the first opening curly brackets indicate?
The beginning of the class code
What does the absence of a semi-colon lead to?
A compile time error
What is the source file?
The file saved with the .java extension
What is the extension for the machine language?
.class extension
Where is the compiled code stored?
After successful compilation, the Java compiler creates a machine language file (a bytecode file with the .class extension) in the project location folder
Where are all instances shown in Java?
In the Object Bench, as a red-colored icon
Name the first method which executes when the JVM loads the class for execution?
the main() method
What is the condition for a Java program to run as a stand-alone application?
It needs to have a main() method
Which generation programming language is Java?
Third-generation
What is the machine language for the JVM?
Bytecode
Define object code
The compiler generated machine language version of the source code is called object code
Define Bytecode
The programs written in Java are compiled into a machine language for a virtual computer called Java Virtual Machine. The machine language for this special JVM is called Bytecode.
Which extension are the Bytecode files generated with?
.class
Suppose you create a class named CoolClass in a file, then compile it. What names should the created and compiled Classes have?
Created - CoolClass.java
Compiled - CoolClass.class
The compiler converts a compiled program into a platform independent code that a JVM can understand. Name this code.
Java class file