Week 1 - Intro to Java Flashcards

1
Q

Write a program that prints out “Hello World!”

A

public class HelloWorld {
—-public static void main ( String[] args) {
——–System.out.println(“Hello World!”);
—–}
}

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

What to main types does Java have?

A

Primitive types

Non-Primitive types/Classes

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

What are the primitive types?

A
  • boolean - true/false
  • char - ‘A’ ‘6’
  • int - whole number
  • short - small whole number
  • long - larger whole number
  • float - decimal number
  • double - high precision float
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the non-primitive types?

A
  • Classes
  • Arrays
  • Strings
  • Interfaces
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is scope of a variable?

A

Scope is where a variable can be used in a script. A variable can only be used inside the block in which it was declared.

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

How do you create a variable?

A

In java variables have both a type and a name, so all variables must be declared before use.

int x;

int defines the type of variable and x is the name of the variable.

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