Posts

Showing posts from February, 2021

Explanation of public static void main in Java

Image
 In java , we have encountered a most common syntax many times which is something like this- We all have written this code when we are first introduced with java. But , most of us are unaware about what this codes says. What is the use of public static void main() and why it is always written like this , no matter how much the length of code. Its format is still the same. Lets try to understand this one by one - public - This public keyword is an access modifier. Now , what access modifier is ? It is used to help to know who can access the method or variable. There are 4 types of access modifiers - public , protected, private and default. This main method is declared as public so that we JVM can invoke it outside of the class and evryone can access it to provide output. If it is changed to any other modifier then JVM would not be able to access it and main method will not invoked by it causing error that - main class not found. static-  It is also a keyword which helps main me...

Why Java is not pure Object Oriented Language?

 Everyone says that java is a pure object oriented programming language. It covers all OOPs concepts but that is not really true. I'll prove it why. So, there are three points which is contradicting the fact that java is not pure object oriented language. firstly , Java doesn't support multiple inheritance. As, we know that there is no concept of multiple inheritance in java because a class can only extends one class. In other words, a class can only have a single parent . This is violating the OOPs which supports multiple inheritance. Secondly, Java has primitve data types. Java has int, long , bit, short etc data types but in OOPs we can't have primitive data types. This proves that java is not purely Object oriented programming language. Third, Java main method run without the use of its class object. As we can see , we never have to call the main method using dot operator which we generally do on calling any method like- a.sum(); so ,by these three points , we can say j...