Posts

Showing posts from March, 2023

CoreJava - FAQs - Part 1

  Core Java - FAQs -  Part 1 Q: What is a static variable in Java? A: A static variable in Java is a variable that belongs to the class itself, rather than to any individual instance of the class. Static variables are shared among all instances of the class and can be accessed using the class name rather than an instance variable. Q: What is a static method in Java?  A: A static method in Java is a method that belongs to the class itself, rather than to any individual instance of the class. Static methods can be called using the class name rather than an instance variable, and they cannot access non-static data members or methods. Q: What is the difference between a public and a private variable in Java?  A: A public variable in Java can be accessed and modified by any code that has access to the object, while a private variable can only be accessed and modified by code within the same class. Q: What is encapsulation in Java?  A: Encapsulation is the practice of...

CoreJava-6 - OOP - Inheritance

     Core Java - OOP - Inheritance   Define Object-oriented programming (OOP) Object-oriented programming (OOP) is a programming paradigm that is based on the concept of objects, which can contain data and code to manipulate that data. In OOP, the focus is on creating objects that interact with each other to perform tasks, rather than on procedures and functions. The key principles of OOP include: Encapsulation: Encapsulation is the practice of hiding the internal details of an object and providing a public interface for interacting with that object. This helps to ensure that the object is used correctly and prevents external code from accessing or modifying its internal state directly. Inheritance: Inheritance is the ability of a class to inherit properties (fields and methods) from a parent class. This allows for code reuse and the creation of complex class hierarchies. Polymorphism: Polymorphism is the abilit...