Posts

Showing posts from April, 2021

JAVA: final, finally, finalize

Difference between final, finally, finalize In JAVA  final final is a modifier accessible for class, method and variables Class declared as final then you can not extend that class. You can not create child class for that class. Method declared as final than you can not override that method in the child class. Variable declared as a final then that variable become constant and you can not change its value. finally  finally is a block in java used in exceptional handling  always associated with try and catch to maintain cleanup code eg. try {    // Risky code ( the code might raise       //exception) } catch {   // Handling code ( the code to handle the   //exception } {    cleanup code } finally meant for cleanup activities related to try block. finalize finalize is a method always invoked by garbage collector just before vanishing an object to perform cleanup activities.  finalize meant for cleanup activiti...

JAVA: Difference between JDK, JVM and JRE

What is difference between JDK, JRE and JVM? JDK --> Java Development Kit  JRE --> Java Runtime Environment JVM--> Java Virtual Machine To develop and run the Java software JDK is used by developer whereas to only run java software at client side JRE is required It means you as a developer should install JDK in your system in order to develop and run for testing the Java application whereas if your client as a end user wants to only run java application then client must install JRE in their system. JVM is an Interpreter which makes Java platform independent. JVM actually convert bytecode into machine code. JDK consist consist of JRE and development tools while JRE consist of JVM and Libraries JDK = JRE + JVM 

self and __init__ in Object oriented Python

Let's first observe below Python code  # Python code for planet name, radius and it's distance from the star. class Planet:              def __init__ (self, name, radius, distance):                  # constructor                      self.name = name                      self.radius= radius                      self.distance=distance              def system (self):                      print (" Name of the planet: ", self.name)                      print (" Radius of the planet: ", self.radius)                       print (" Distance from the ...