A Trip to Objectville — Chapter 2
There are two places where the main() method is used in Java
- To test you real class
- To launch/start your Java application
Steps to analyze a question in Object Oriented Concepts.
- Identify what the object knows about itself — instance variables
- Identify what the object can do — methods
Things to Note:
- To find a random number between 0 and 9 the following can be used,
int n = (int) (Math.random() * 10);
- When an end-user system is not Java installed, the platform specific JVM could be packaged alongside the compiled program for execution.
Heap : Each time an object is created, it is saved (memory allocation)on the “Heap” (aka the Garbage-Collectible Heap), where the space allocated depends on the number and size of the instance variables of the object.
Static: Marking a method/variable as public and static makes it reachable from anywhere in the code (globally available).
final: Marking a method/variable as public, static and final makes a constant reachable from anywhere in the code (globally-available constant).
JAR file: .Jar file aka a Java Archive file is a package based on the pkzip format, where all the necessary application files could be bundled up together. A simple text file named as manifest is used to define where the main() lies inside the jar.
Other than that, not much on this chapter. Thanks for reading. Until next time! 👋🏽