Basics of Java Flashcards

1
Q

Why is Java so useful?

A

the Java Virtual Machine ensures the same Java code can be run on different operating systems and platforms (MacOs, Windows API, UNIX) - Sun Microsystems’ slogan for Java was “write once, run everywhere”.

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

The difference between System.out.println() & System.out.print()?

A

Unlike System.out.println(), this type of print statement outputs everything on the same line.

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

What are the three types of comments you can make?

A

When comments are short we use the single-line syntax: //

When comments are long we use the multi-line syntax: /* and */

the Javadoc comment which is represented by /** and */. Javadoc comments are used to create documentation for APIs

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

What is the purpose of the compiler in Java?

A

he code we write in a .java file is transformed into byte code by a compiler before it is executed by the Java Virtual Machine.

The compiling process catches mistakes before the computer runs our code. Code that does not pass these checks will not be compiled.

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

What is the terminal command to compile a file?

A successful compilation produces a .class file: Plankton.class. What is the terminal command we execute?

A

javac Plankton.java

java Plankton

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

What happens to an unsuccessful compilation?

A

An unsuccessful compilation produces a list of errors. No .class file is made until the errors are corrected and the compile command is run again.

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

What is an IDE?

A

enables programmers to consolidate the different aspects of writing a computer program

increase programmer productivity by combining common activities of writing software into a single application: editing source code, building executables, and debugging.

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

How do IDEs facilitate editing source code

A

They have features like syntax highlighting and autocomplete

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

How do IDEs facilitate syntax highlighting?

A

By providing visual cues. Keywords, words that have special meaning like class in Java, are highlighted with different colors. Syntax highlighting makes code easier to read by visually clarifying different elements of language syntax.

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

How do IDEs facilitate autocomplete?

A

It can anticipate what you’re going to type next!

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

how does IDE facilitate debugging?

A

IDEs provide debugging tools that allow programmers to examine different variables and inspect their code in a deliberate way.

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

What is a string?

What are the two ways to create a String object?

A

A String literal is any sequence of characters enclosed in double-quotes (“”)

we declare a String variable by specifying the type first:
~~~
String greeting =”Hello World”;
~~~

We could also create a new String object by calling the String class when declaring a String like so:
~~~
String salutations =new String(“Hello World”);
~~~

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

How can we add quotation marks and backslashes to a String value?

A

The " escape sequence:

System.out.println(“"Hello World"”);
// Prints: “Hello World”

the \ escape sequence :

System.out.println(“This is the backslash symbol: \”);
// Prints: This is the backslash symbol: \

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