Core Java -101 Flashcards
Can we do array[i] and i could be long type also?
No i must be only int
What is a Runtime class?
Every Java Application has one instance of this , this will allow instance to interface with env it is running
How to obtain the Runtime?
getRuntime
What is addShutdownHook(Thread hook)
Registers a new virtual-machine shutdown hook.
What is exec methods?
So this has many overloads & use to give the commands on the given environment
exit(int status)
Terminates the currently running Java virtual machine by initiating its shutdown sequence.
freeMemory()
Returns the amount of free memory in the Java Virtual Machine.
gc()
Runs the garbage collector.
halt(int status)
Forcibly terminates the currently running Java virtual machine.
loadLibrary(String libname)
Loads the dynamic library with the specified library name.
removeShutdownHook(Thread hook)
De-registers a previously-registered virtual-machine shutdown hook.
totalMemory()
totalMemory()
Returns the total amount of memory in the Java virtual machine.
What the exec method returns?
Process
What is a java.lang.Process class?
The ProcessBuilder.start() and Runtime.exec methods create a native process and return an instance of a subclass of Process that can be used to control the process and obtain information about it. The class Process provides methods for performing input from the process, performing output to the process, waiting for the process to complete, checking the exit status of the process, and destroying (killing) the process.
Does the methods of PRocess works in all env?
Not necessarily all, may fail is some basic env