In Java protected Keyword
Protected specifiers allows the class itself, subclasses, and all classes in the same package to access the members. You should use the protected access level for those data members or member functions of a class, which you can be accessed by subclasses of that class, but not unrelated classes. You can see protected members as family secrets–you don’t mind if the whole...
Thursday, 27 April 2017
Private Keyword in Java
Private Keyword in Java
Private is the most restrictive access level. A private member is accessible only to the class in which it is defined. You should use this access to declare members that you are going to use within the class only. This includes variables that contain information if it is accessed by an outsider could put the object in an inconsistent state, or methods, if invoked by an outsider,...
ACCESS CONTROL in Java
ACCESS CONTROL in Java
One of the objectives of having access control is that classes can protect their member data and methods from getting accessed by other objects. Why is this important? Well, consider this. You’re writing a class that represents a query on a database that contains all kinds of secret information; say student’s records or marks obtained by a student in final examination.In...
Superclass and Subclass in Java
Superclass and Subclass in Java
The superclass of a class A is the class from which class A is derived. In programming languages like C++, allow deriving a class from multiple classes at a time. When a class inherits from multiple super classes, the concepts is known as multiple inheritance. Java doesn’t support multiple inheritance. If there is a need to implement multiple inheritance.
A class...
Inheritance in Java
Inheritance is a language property specific to the object-oriented paradigm. Inheritance is used for a unique form of code-sharing by allowing you to take the implementation of any given class and build a new class based on that implementation. Let us say class B, starts by inheriting all of the data and operations defined in the class A. This new subclass can extend the behaviour by adding additional...
Java inheritance in programming
In Object Oriented Programming, one of the major feature is reusability. You are already introduced to the reusability concept in this course. Reusability in Java is due to the inheritance. Inheritance describes the ability of one class or object to possess characteristics and functionality of another class or object in the hierarchy. Inheritance can be supported as “run-time” or “compile-time” or...
Subscribe to:
Posts (Atom)