Java Flashcards

1
Q

java: to write a comment type

A

//

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

java: java filenames end with

A

.java

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

java: Java is a

A

compiled language

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

java: a compiled language is one that

A

must be converted from human readable code to computer readable code before running.

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

java: javac is short for

A

java compiler

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

java: To run a java file that you have already compiled you type

A

java Filename

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

java: To compile a java file and then run it, type

A

javac Filename.java double ampersand

java Filename

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

java: Variables in java require you to

A

specify their type

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

java: To create a string variable, type

A

String myString = “string”;

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

java: To print a string with a variable in it to the console, type

A

console.printf(“I’m %s”, “Alen”)

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

java: do not forget

A

to end lines with a semicolon

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

java: To accept a user input into the console into a variable, type

A

String myString = console.readLine(“string”);

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

java: a multi line comment is denoted with

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

java: Java’s variable types are

A

int
String
boolean

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

java: To write a conditional statement, type

A

if (10 == 10) {

}

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

java: The global object that controls the system is called

A

System

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

java: To make the system object exit, type

A

System.exit(0);

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

System: Any exit code other than 0 means

A

that the program exited abnormally.

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

System: an exit code of 0 means

A

that the program exited intentionally.

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

java: To convert a string to an int, type

A

Integer.parseInt(intString);

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

java: To return a boolean of whether a string variable is the same as another string, type

A

myString.equals(“string”);

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

java: To return a boolean of whether a string variable is the same as another string case insensitive, type

A

myString.equalsIgnoreCase(“string”);

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

java: the “or” character for conditional statements is

A

||

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

java: the “and” character for conditional statements is

A

double ampersand

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

java: To run some code before entering a while loop, type

A

do {

} while {

}

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

java: Variables declared inside the do while loop are

A

not available outside it

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

android: IDE stands for

A

integrated development environment

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

android: Software you can write android apps in is called

A

Android Studio

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

android: When creating an android project, the package name

A

is your unique identifier that differentiates you from other developers on the play store. Make it unique upfront.

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

android: When creating an android project, the project name

A

is the name you will see in the play store, so make it correct up front.

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

android: Gradle is

A

the build system that builds android apps

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

android: To run your android app on your computer

A
press play on the toolbar 
press "..."
build an emulator
Make sure to use an "armeable" version of android. and keep the rest defaults
press play again in the toolbar again
choose the emulator in the dropdown
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

android: to regenerate all of the files

A

click the menu option, “build” then “clean project” and then “rebuild project”

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

android: The minimum SDK is

A

the lowest version of android our app works on.

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

android: To view almost any section of Android Studio

A

click the square in the bottom left corner and click on it in the dropdown

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

android: The file main/res contains

A

all of the resources or static files of the app

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

android: The file main/res/layout contains

A

all of the screens/views

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

android: Build time errors appear in

A

the bottom toolbar option “messages”

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

android: Run time errors appear in

A

the bottom toolbar option “android”

40
Q

android: To change a view visually instead of using code,

A

click the “design” tab

41
Q

android: To set textSize to be size that is relative to the screen size, type

A

10sp

42
Q

android: To make an element stretch to the outer edges or shrink to just fit it content

A

click the double arrows above the phone preview

43
Q

android: It is better to change the id of an element in the

A

design tab instead of the xml tab because it automatically changes all references to that id as well, while the code does not

44
Q

android: A view in android is

A

a page element

45
Q

android: A relative layout is

A

the container page that holds the views

46
Q

android: An easy way to get rid of the action bar is to

A

go to values/styles.xml and change the theme to one with no action bar

47
Q

android: The meta information of an app like name, theme, icon are saved in

A

AndroidManifest.xml

48
Q

java: To clear the java repl, type

A

:cls

49
Q

java: To return a boolean of whether or not a substring is contained in a string, type

A

myString.contains(“string”);

50
Q

java: To lower case a string, type

A

myString.toLowerCase();

51
Q

java: To compare two numbers and return a boolean, type

A

1 > 2;

52
Q

java: a class attribute is also called a

A

member variable

53
Q

java: Member variable names are often prepended with

A

the letter “m” by convention

54
Q

java: an alternative to console.printf(“string”); is

A

System.out.printf(“string”);

55
Q

java: To create a public class with a public member variable, type

A
public class ClassName {
    public String mMyString = "string";
}
56
Q

java: To make a classes member variable private, type

A
public class ClassName {
    private String mMyString = "string";
}
57
Q

java: Making a member variable private

A

prevents access to it.

58
Q

java: The only way to access or alter a private member variable is

A

to use a method that returns it

59
Q

java: To create a method, type

A

public String getString() {
return mMyString;
}

60
Q

java: methods that return a property of a class are often

A

prepended with “get”

61
Q

java: methods that change a property of a class are often

A

prepended with “set”

62
Q

java: To declare but not initialize a variable, type

A

public String myString;

63
Q

java: To create a constructor method that takes a string argument upon instantiation, type

A
public ClassName(String myString) {
  mMyString = myString;
  }
64
Q

java: To instantiate a class, type

A

ClassName classNameInstance = new ClassName(param1);

65
Q

java: Variables that do not change are called

A

constants

66
Q

java: Constants are written by convention as

A

all caps separated by underscores.

67
Q

java: the screen layouts are located in

A

main/res/layout

68
Q

java: To create an integer variable that is a constant and cannot be changed, type

A

public final int MY_INT = 10;

69
Q

java: A class level variable is

A

a member variable that can be accessed from the class without creating an instance

70
Q

java: To create a class level variable, type

A

public static String myString = “string”;

71
Q

java: To import a java file into the repl in order to access its classes, type

A

:load FileName.java

72
Q

java: To access a class level variable, type

A

ClassName.mMemberVariable;

73
Q

java: To access a class level method, type

A

ClassName.getMethod(param1);

74
Q

java: To create a method that returns nothing, type

A

public void myMethod() {

}

75
Q

java: final is usually

A

the last modifier before the Type

76
Q

java: To create a class level method, type

A

public static String getString() {
return mMyString;
}

77
Q

java: When you run a java file, it

A

searches the file for a static method named main and runs it.

78
Q

java: To invert true, type

A

!true

79
Q

java: post incrementing means

A

returning the value of the variable before incrementing it

80
Q

java: pre incrementing means

A

returning the value of the variable after incrementing it

81
Q

java: To post increment or decrement a variable, type

A

myInt++ or myInt–

82
Q

java: To pre increment decrement a variable, type

A

++myInt or –myInt

83
Q

java: To write a while loop, type

A

while (10 == 10) {

}

84
Q

java: Multiple methods can

A

have the same name as long as their parameters are different

85
Q

java: To raise an exception, type

A

throw new ExceptionName(“string”);

86
Q

java: To create a try/catch block, type

A

try {

} catch(ExceptionName exVar) {

}

note: exVar is the variable that allows you to access attributes of the exception, like the message

87
Q

java: In java, everything is

A

a class

88
Q

java: To create a .java files main method, type

A
public class Filename {
  public static void main (String[] args) {
    ...
  }
}
89
Q

java: A char is

A

a data type that is one letter surrounded by single quotes

90
Q

java: To return the index of a sub string, type

A

myString.indexOf(myChar);

91
Q

java: if myString.indexOf(“string”); is not found

A

it returns -1

92
Q

java: To concatenate a string and char, type

A

myString = myString + ‘a’;
or
myString += ‘a’;

93
Q

java: To create an if and an else statement, type

A

if (10==10) {

} else {

}

94
Q

java: You cannot pass myString.contains()

A

a char, because it is not converted

95
Q

java: you can use myString.indexOf() on

A

a char, because it gets converted

96
Q

java: To denote that a method is overriding a method inherited from a superclass, type

A

add the annotation @Override