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 |
Does java linked list allow duplicates?
What is the use of beaninfo?
What is a predicate method?
What is casting?
Hi Anyone know the model / questions of the Federal bank sample questions for the post of Specialist Officers - Programmers. Please post if anyone have..
what is default constructor and parameterised constructor with example?
How is java hashmap implemented?
What classes of exceptions may be caught by a catch clause in java programming?
Is it necessary that each try block must be followed by a catch block?
what is the use of Clonable,and serializable interface?
What are the two categories of data types in the java programming language?
What is var keyword ?