Object Oriented Programming is a paradigm that provides many concepts such as inheritance, encapsulation, polymorphism etc. surprisingly these three major OOPs concept are present in your small simple Hello World program also. I am trying to prove that, please find below the clarifications
1. Use of Inheritance concept in your program
The Object class, in the java.lang package, sits at the top of the class hierarchy tree. Every class is a descendant, direct or indirect, of the Object class. Every class you use or write inherits the instance methods of Object.
So although you did not extend any class but still your Day1 class implicitly extending Object class and inherits all the methods of Object class. So you already used inheritance concept here.
2. Use of Encapsulation concept in your program
Encapsulation in Java or object oriented programming language is a concept which enforce protecting variables, functions from outside of class, in order to better manage that piece of code and having least impact or no impact on other parts of program due to change in protected code.
Encapsulation can be achieved via access specifiers in Java and you already applied encapsulation concept in your program. You declared your main method with access specifier Public – so that main method can be called by JVM. You made this public to permit call from outside of the application.
3. Use of Polymorphism concept in your program
Polymorphism in the context of object-oriented programming, is the ability to create a variable, a function, or an object that has more than one form
System.out.println("Java drives the web");
Here you used println() method of PrintStream class. If you go to the source code of the PrintStream class, you will find ten methods are present in this class with same name println but with different parameters.In short PrintStream class contains different overloaded method. So you also used Compile time polymorphism (static binding or method overloading) here.
If you are only talking about object, then probably you got your answer from @MadConan
Answer from @MadConan
There are many objects in your code
- class day1: This is your Class.
- Class is an object. args[]: This is
an object of type array. System:
- The System object is available
everywhere. It's part of the core API.
- out: This is the PrintWriter
object instance which is a member of the System object.
- "Java drives
the web": That is a String object.
Just because you never use the new keyword doesn't mean you aren't using any objects.