Java Programming Flashcards

1
Q

What does IDE stand for?

A

Integrated Development Environment

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

What file type is java source code stored in?

A

.java files

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

What happens during compiling?

A

.java file is compiled to produce a .class file. The .class file is then interpreted by the Java Virtual Machine

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

What is in a .class file?

A

a sort of generic machine language called Java Byte Code

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

What are the benefits of .class files?

A

very portable: anyone with a JVM can run it on any platform
secure: .class file is unreadable to humans

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

How do you run a java program you write on the command prompt?

A

javac <programName>.java -> compiles the code (to get the .class file)</programName>

java <programName> -> interprets the compiled code and runs your program</programName>

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

How do you write a string that must be broken up over multiple lines.

A

You cannot break a String literal over two or more lines. You must use the + operator

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

What are the primitive types?

A

integer types: int, long, short, byte
floating point types: double, float
others: char, boolean

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

When should you use and integer type other than int?

A

long should be used when you require numbers above 2 billion or below -2 billion. You must put an L at the end of a literal bigger than 2 billion

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

What type does 1.0 default to?

A

Double. To get a float, you must put an f at the end

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

What do you get from
‘a’ + true
‘a’ + 1

A

error
‘b’

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

how do you store a number as a string?

A

you must put it in quotes for literals or cast it with Integer.toString(variableName) or ““+variableName

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

What does the static keyword do?

A

Makes it into a global variable that is accessible anywhere in the class

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

What are the formatting codes?

A

%d - print a decimal integer here
%6d - use at least 6 characters to do that
%f - print a floating point value here
%6f - use at least 6 characters to do that
%6.2 - with exactly 2 of them after the decimal point
%s - print a String here
%n - print a newline character

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

How do you get a string input from the console?
What about an int?

A

Scanner in = new Scanner(System.in);
in.nextLine();
in.nextInt();

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

What are some escape characters?

A

\ - gives a backslash character
\n - gives a newline character
\t - gives a tab character

17
Q

What are some String methods?

A

s.equals(“string”);
s.equalsIgnoreCase(“string”);
s.length();
s.charAt(1);