What are the basic concepts of OOPS in java?



What are the basic concepts of OOPS in java?..

Answer / Vaibhav Chittranshi

In Java, Object-Oriented Programming (OOP) is based on four main principles:n- Encapsulation: Hiding the internal details and providing a public interface.n- Inheritance: One class acquiring properties and methods of another class.n- Polymorphism: The ability to use an object in many different ways.n- Abstraction: Representing complex real-world objects in a simple way.nFor example:n```javanclass Animal {n private String name;n public void setName(String name) {n this.name = name;n }n public String getName() {n return name;n }n}nclass Cat extends Animal {n private int age;n public void setAge(int age) {n this.age = age;n }n public int getAge() {n return age;n }n}nCat cat = new Cat();ncat.setName("Tommy");nsystem.out.println(cat.getName()); // Output: Tommyn```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

Does java linked list allow duplicates?

1 Answers  


What is the use of beaninfo?

1 Answers  


What is a predicate method?

1 Answers  


What is casting?

3 Answers  


Hi Anyone know the model / questions of the Federal bank sample questions for the post of Specialist Officers - Programmers. Please post if anyone have..

1 Answers  


what is default constructor and parameterised constructor with example?

1 Answers   KPIT,


How is java hashmap implemented?

1 Answers  


What classes of exceptions may be caught by a catch clause in java programming?

1 Answers  


Is it necessary that each try block must be followed by a catch block?

1 Answers  


what is the use of Clonable,and serializable interface?

1 Answers  


What are the two categories of data types in the java programming language?

1 Answers  


What is var keyword ?

1 Answers   Wipro,


Categories