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
java: To run some code before entering a while loop, type
do { } while { }
26
java: Variables declared inside the do while loop are
not available outside it
27
android: IDE stands for
integrated development environment
28
android: Software you can write android apps in is called
Android Studio
29
android: When creating an android project, the package name
is your unique identifier that differentiates you from other developers on the play store. Make it unique upfront.
30
android: When creating an android project, the project name
is the name you will see in the play store, so make it correct up front.
31
android: Gradle is
the build system that builds android apps
32
android: To run your android app on your computer
``` 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 ```
33
android: to regenerate all of the files
click the menu option, "build" then "clean project" and then "rebuild project"
34
android: The minimum SDK is
the lowest version of android our app works on.
35
android: To view almost any section of Android Studio
click the square in the bottom left corner and click on it in the dropdown
36
android: The file main/res contains
all of the resources or static files of the app
37
android: The file main/res/layout contains
all of the screens/views
38
android: Build time errors appear in
the bottom toolbar option "messages"
39
android: Run time errors appear in
the bottom toolbar option "android"
40
android: To change a view visually instead of using code,
click the "design" tab
41
android: To set textSize to be size that is relative to the screen size, type
10sp
42
android: To make an element stretch to the outer edges or shrink to just fit it content
click the double arrows above the phone preview
43
android: It is better to change the id of an element in the
design tab instead of the xml tab because it automatically changes all references to that id as well, while the code does not
44
android: A view in android is
a page element
45
android: A relative layout is
the container page that holds the views
46
android: An easy way to get rid of the action bar is to
go to values/styles.xml and change the theme to one with no action bar
47
android: The meta information of an app like name, theme, icon are saved in
AndroidManifest.xml
48
java: To clear the java repl, type
:cls
49
java: To return a boolean of whether or not a substring is contained in a string, type
myString.contains("string");
50
java: To lower case a string, type
myString.toLowerCase();
51
java: To compare two numbers and return a boolean, type
1 > 2;
52
java: a class attribute is also called a
member variable
53
java: Member variable names are often prepended with
the letter "m" by convention
54
java: an alternative to console.printf("string"); is
System.out.printf("string");
55
java: To create a public class with a public member variable, type
``` public class ClassName { public String mMyString = "string"; } ```
56
java: To make a classes member variable private, type
``` public class ClassName { private String mMyString = "string"; } ```
57
java: Making a member variable private
prevents access to it.
58
java: The only way to access or alter a private member variable is
to use a method that returns it
59
java: To create a method, type
public String getString() { return mMyString; }
60
java: methods that return a property of a class are often
prepended with "get"
61
java: methods that change a property of a class are often
prepended with "set"
62
java: To declare but not initialize a variable, type
public String myString;
63
java: To create a constructor method that takes a string argument upon instantiation, type
``` public ClassName(String myString) { mMyString = myString; } ```
64
java: To instantiate a class, type
ClassName classNameInstance = new ClassName(param1);
65
java: Variables that do not change are called
constants
66
java: Constants are written by convention as
all caps separated by underscores.
67
java: the screen layouts are located in
main/res/layout
68
java: To create an integer variable that is a constant and cannot be changed, type
public final int MY_INT = 10;
69
java: A class level variable is
a member variable that can be accessed from the class without creating an instance
70
java: To create a class level variable, type
public static String myString = "string";
71
java: To import a java file into the repl in order to access its classes, type
:load FileName.java
72
java: To access a class level variable, type
ClassName.mMemberVariable;
73
java: To access a class level method, type
ClassName.getMethod(param1);
74
java: To create a method that returns nothing, type
public void myMethod() { }
75
java: final is usually
the last modifier before the Type
76
java: To create a class level method, type
public static String getString() { return mMyString; }
77
java: When you run a java file, it
searches the file for a static method named main and runs it.
78
java: To invert true, type
!true
79
java: post incrementing means
returning the value of the variable before incrementing it
80
java: pre incrementing means
returning the value of the variable after incrementing it
81
java: To post increment or decrement a variable, type
myInt++ or myInt--
82
java: To pre increment decrement a variable, type
++myInt or --myInt
83
java: To write a while loop, type
while (10 == 10) { | }
84
java: Multiple methods can
have the same name as long as their parameters are different
85
java: To raise an exception, type
throw new ExceptionName("string");
86
java: To create a try/catch block, type
try { } catch(ExceptionName exVar) { } note: exVar is the variable that allows you to access attributes of the exception, like the message
87
java: In java, everything is
a class
88
java: To create a .java files main method, type
``` public class Filename { public static void main (String[] args) { ... } } ```
89
java: A char is
a data type that is one letter surrounded by single quotes
90
java: To return the index of a sub string, type
myString.indexOf(myChar);
91
java: if myString.indexOf("string"); is not found
it returns -1
92
java: To concatenate a string and char, type
myString = myString + 'a'; or myString += 'a';
93
java: To create an if and an else statement, type
if (10==10) { } else { }
94
java: You cannot pass myString.contains()
a char, because it is not converted
95
java: you can use myString.indexOf() on
a char, because it gets converted
96
java: To denote that a method is overriding a method inherited from a superclass, type
add the annotation @Override