we know that every java prog must follows OOPS Principles.
Anybody can answer, HOW THE FOLLOWING PROGRAM FOLLOWS OOPS
CONCEPTS i.e, Inheritance,Polymarphism,Encapsulation?
class a{
public static void main(String args[]){
System.out.println("Hello World");
}
}
Answers were Sorted based on User's Feedback
Answer / srinivas battula
Java is Pure OOPS... Try writing a java program without
Class. i.e. public class Test {}, In this way it satisfies
Oops Concept.
Abstraction: Take any thing like static, system,etc. we
don't know the internal functionalities, but by calling
them we are achieving the task. Here it is hiding the
complexities but representing essential features.
Encapsulation: By writing a program you are grouping all
the methods, variables,etc there by satisfying Encapsulation
Inheritence: When reusability occurs, you satisfy this
concept.
Polymorphism: We achieve it through Overloading and
Overriding in Java in most of the concepts.
Is This Answer Correct ? | 4 Yes | 1 No |
Inheritance: Every class is extended of Object class, so in
here a extends Object. this is Inheritance.
Polymorphism: means single entity multiple views.
here only one method is there. if here multiple views, then
only it would become like Polymorphism concept.
Encapsulation: Wrapping up of data and code means methods,
variables, code, and all. every java program is based on
Encapsulation concept.
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / dhawal
1]here we use static main method means single copy of that
method is created in memory for that particular class means
we can not accept main method out side the class we can call
this method by using class name,ie javac a.java means this is
ENCAPSULATION
2]here println is a method, its defination writen in out
that is output straem means we obtain
INHERITANCE
3]polymorphisum means one name many form basically base
class pointer in our example when u pass String args[] to
main but can manipulate all type of data inside main this is
POLYMORPHISUM
Is This Answer Correct ? | 2 Yes | 0 No |
Which command from the jdk compiles a java program?
Why ArrayList class is not a synchronized class and why it is not a thread safe class? explain
Which types of exceptions are caught at compile time?
What is vector?
What are different types of states exist for a thread?
Life Cycle of Thread
How do you check if two strings are equal in java?
what is default layout of JFrame class?
what is the use of datasource in core java?
what is the difference between sleep() and Wait()?
what is the difference between Java Command Line and C command Line?
Write a program to print 15 random numbers using foreach of java 8?