Intro to Java Flashcards

1
Q

What is Java?

A

Java is a full-featured, general-purpose object-oriented programming language that can be used to develop robust mission-critical applications

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Who developed Java and where?

A

Java was started as a project called “Oak” by James Gosling in June 1991 at Sun Microsystems

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why was there a need for platform-independent language?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the term platform refer to?

A

The term platform refers to a specific combination of hardware and system software (operating system)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Define platform independence

A

The capability of a computer program to run on multiple platforms is referred to as platform independence

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When was Java formally released?

A

In 1995 - Oak was renamed Java

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

When did Oracle acquire Sun Microsystems?

A

2010

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Name the two types of Java programs

A
  1. Stand-alone applications

2. Internet applets

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a stand-alone java program?

A

It refers to a Java program that can run independently on a computer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Give an example of a stand-alone java program

A

Acrobat PDF Reader

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What can stand-alone java programs be based on?

A

They can either be console-based or with a Graphical User Interface (GUI)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does a Console-based Java application use?

A

Uses a text-only interface

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does a GUI-based Java application use?

A

Uses a graphical interface, such as command buttons, text fields, and a mouse

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are Java applets?

A

The Java programs that run in a web browser are called Java applets.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are applets used for?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How can applets be transported?

A

They can be transported over the internet from one computer to another through a Java-enabled browser or an applet viewer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is machine language?

A

Computers were developed to carry out instructions that were written in their native language called machine language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is machine code?

A

Machine language instructions are expressed as binary numbers called machine code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is a binary no. made up of?

A

Just two digits - zero (0) and one (1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is each digit in a binary no. called?

A

Each digit, zero or one, is called a bit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

A machine language instruction is just a sequence of _ and _

A

zeros and ones

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Why does the machine code of one type of computer differ from another?

A

Different computers use different sets of binary codes for each instruction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

When can a computer directly execute a program?

A

Only when the program is written in the computer’s machine language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

State the issues with programming in machine language

A

It was a tedious process and was prone to errors. In addition to this, these programs were very difficult to read and modify

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

Why were assembly languages developed?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What were assembly languages?

A

These allow programs to be written using symbolic operations called mnemonic codes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

What mnemonic code can you use for 100101?

A

ADD

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What was the issue with assembly languages and what was its solution?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

What is an assembler?

A

An assembler is a program that translates an assembly language program into machine code

30
Q

When did high-level programming languages emerge? What were they?

A

In the 1950s. A high-level language is quite similar to the English language and is easy to learn and use

31
Q

What is a source code or source program?

A

A program written in a high-level programming language is called a source program

32
Q

What is an interpreter?

A

An interpreter is a program that translates the source code instructions into machine code line-by-line.

33
Q

How does the interpreter work?

A

It runs in a loop, reading the next statement from the source code and translating it into the necessary machine code.

34
Q

What is a compiler?

A

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

35
Q

What is the object code?

A

The object code is the machine language version of the source code

36
Q

What is the difference between the execution of an interpreter and a compiler?

A

The execution of an interpreted program is slow, whereas the execution of a compiled program is fast

37
Q

What happens in the traditional compilation process?

A

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.

38
Q

What happens in the Java compilation process?

A

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.

39
Q

What is the extension for the Java source code file?

A

.java

40
Q

What is the extension for the Bytecode file?

A

.class

41
Q

What is the role of executable code in computing?

A

In computing, executable code or an executable file causes a computer to “perform a series of instructions when it is opened”.

42
Q

What is a JIT compiler?

A

A Just-In-Time compiler is a part of JVM that compiles selected portions of Bytecode into executable code

43
Q

What is JRE?

A

JRE is an acronym for Java Runtime Environment. The JVM, along with many other class libraries, constitutes the JRE.

44
Q

Name the features of Java

A
  1. Object-Oriented
  2. Robust
  3. Platform Independent
  4. Simple
  5. Secure
  6. Multithreaded
45
Q

Why is JAVA an OOP language?

A

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

46
Q

Why is Java a robust and reliable programming language?

A

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

47
Q

How is Java platform independent?

A

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.

48
Q

What has simplified Java’s understanding and implementation?

A

The removal of many unreliable features of C and C++ (its predecessors)

49
Q

How is Java secure?

A

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.

50
Q

Why is Java considered a robust and reliable programming language?

A

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.

51
Q

Why is Java considered a multithreaded programming language?

A

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.

52
Q

What is BlueJ?

A

BlueJ is an Integrated Development Environment (IDE) specifically designed for teaching Java at an introductory level.

53
Q

What does the GUI provided by BlueJ contain?

A
  1. Code Editor - to write the program code
  2. Java Compiler - to compile your code
  3. Virtual Machine - to execute the java program
  4. Terminal - to view the output
  5. Debugger - to find problems in the code
54
Q

What is the keyword public?

A

It is an access specifier that defines the scope of the class

55
Q

What does the keyword class denote?

A

That this is the class with the name ‘whatever’

56
Q

What is void?

A

Void is a keyword which signifies that this method will not return a value

57
Q

What do the first opening curly brackets indicate?

A

The beginning of the class code

58
Q

What does the absence of a semi-colon lead to?

A

A compile time error

59
Q

What is the source file?

A

The file saved with the .java extension

60
Q

What is the extension for the machine language?

A

.class extension

61
Q

Where is the compiled code stored?

A

After successful compilation, the Java compiler creates a machine language file (a bytecode file with the .class extension) in the project location folder

62
Q

Where are all instances shown in Java?

A

In the Object Bench, as a red-colored icon

63
Q

Name the first method which executes when the JVM loads the class for execution?

A

the main() method

64
Q

What is the condition for a Java program to run as a stand-alone application?

A

It needs to have a main() method

65
Q

Which generation programming language is Java?

A

Third-generation

66
Q

What is the machine language for the JVM?

A

Bytecode

67
Q

Define object code

A

The compiler generated machine language version of the source code is called object code

68
Q

Define Bytecode

A

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.

69
Q

Which extension are the Bytecode files generated with?

A

.class

70
Q

Suppose you create a class named CoolClass in a file, then compile it. What names should the created and compiled Classes have?

A

Created - CoolClass.java

Compiled - CoolClass.class

71
Q

The compiler converts a compiled program into a platform independent code that a JVM can understand. Name this code.

A

Java class file