Beginning Java Flashcards
Learn all the things.
What are Java packages used for?
- Java packages are used to bundle related functionality and programs.
What is this called? %s
- That is a format specifier.
Why would you use %n instead of \n for a new line?
- The reason for this is that Windows and Unix based systems (Like Mac and Linux) use different newline sequences. %n makes the proper distinction.
The exit method takes an argument for the status code as shown below. What does 0 mean?
- System.exit(0);
- The 0 argument means that the system exited intentionally.
Primatives have special characteristics about the type of data that they can store, no methods or properties. What are the eight primative data types with Java?
- int
- double
- long
- byte
- char
- float
- short
- boolean
Converting an integer to a string is also called what?
- Parsing an integer out of a string.
- Switching between types like this is also called casting.
Look at the text below, what is Integer? What is parseInt()?
- int x = Integer.parseInt();
- Integer is a class
- This is also known as a wrapper or a boxed type.
- It provides methods for us to use.
- parseInt() is a static method of the Integer class.
- Here we are using the Integer class’ static method of parseInt() to generate a primative int.
What does REPL stand for?
- Read Eval Print Loop
What two things do all real world objects have?
- State and Behavior
What is a blueprint used to create objects in Java?
- A class.
What is special about the System class?
- The System class is automatically imported into a Java application.
What does the System class provide to enable a developer to output information to the console? What is that thing called?
- It provides a static public field called out.
- System.out
- out is a print stream and it exposes some methods that we have seen before for example: println.
- System.out.println(“This is an example.”);
What is a variable called that is defined in the scope of a class definition?
- A field or member variable.
How do you mark a field or member variable as private?
- Put the private keyword before the type declaration.
- Example:
- private String name = “Bob”;
What is the most common way of exposing a class value, but not let someone set it?
- Add a method to your class.