Method Overloading
Parts of Method:
What does continue keyword perform ?
In a loop if you put continue it will start the iterator again from the next index
Word.length
length starts at 1 not 0 index.
Lawn has a length of 4
The index does start at 0
5/2
2
An ArrayList collection ..
Can only store objects and not primitives
Name Standards
packages: always lowercase
ClassNames: start with capital and then do camel case
methods: start with lower case and then camelCase
CONSTANTS: ARE ALL CAPS
What is Stack Memory and what is stored
Ex: Car toyota
What is HEAP memory and how is it used ?
What is String pool ?
Explain what word.toUpperCase does to String value?
Why is a String immutable ?
Special space in HEAP java memory where String objects are places and reused.
- If a string is already exists in String pool java will reuse it. Ex: if “java word” already exists and you do String value = “java word”, the word will not be created in String pool it will simple let value variable name point to “java word”
String name = null
wordNew = word.toUpperCase
- Will go to HEAP and it will point to the uppercase version of the word without changing the word itself. Therefore it is immutable
String word 2 = “hello” + “world”;
String builder vs String Buffer
Both allow us to use other methods to manipulate strings
However, they have different implementations
String input = “Java is good”;
StringBuilding word1 = new StringBuilder(); word1.append(input)
StringBuffer word2 = new StringBuffer(input);
Now you can do word1.reverse();
Encapsulation Principles?
Encapsulation Benefits?
In Encapsulation what is immutable class ?
What is Write-only class?
Write only object? Provide only setters and no getters
Constructors facts:
Person person1 = new Person("Johnny", 20);
Person person1 = new Person("Johnny");
Person person1 = new Person(20);
Person person1 = new Person();What is composition ?
When a class has instance variables of type of another class - HAS-A relationship
Bus:
Properties: Driver, Engine
Bus HAS-A Driver
Bus HAS-A Engine
Static - method related
Static - Variable
Static Block
Static Inner Class
In java, we can create a class inside another class
IQ: Why is main method static ? Related to psvm
Ex:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}So that JRE can call it using. HelloWorld.main(null);