Java Interfaces In Java, an interface outlines a contract for a class. The contract outlined by an interface mandates the methods that must be implemented in a class. Classes implementing the contract must fulfill the entire contract or be declared abstract. Java interfaces are used to define abstract types. Interfaces: Are similar to abstract classes […]
Java
Java Basics: Abstract and Nested Classes
Modeling Business Problems with Classes Class Inheritance When designing an object-oriented solution, you should attempt to avoid code duplication. One technique to avoid duplication is to create library methods and classes. Libraries function as a central point to contain often reused code. Another technique to avoid code duplication is to use class inheritance. When there […]
Java Basics: Overriding Methods, Polymorphism, and Static Classes
Using Access Control The table below illustrates access to a field or method marked with the access modifier in the left column. Modifier (keyword) Same Class Same Package Subclass in Another Package Universe private Yes – – – default Yes Yes – – protected Yes Yes Yes – public Yes Yes Yes Yes The access […]
Beginners Guide to Java Encapsulation and Subclassing
Encapsulation Encapsulation is one of the four fundamental object-oriented programming concepts. The other three are inheritance, polymorphism, and abstraction. The term encapsulation means to enclose in a capsule or to wrap something around an object to cover it. Encapsulation covers, or wraps, the internal workings of a Java object. – Data variables, or fields, are […]
Basics of Java
This post is a review of fundamental Java and programming concepts. Java Class Structure A Java class is described in a text file with a .java extension. In the example shown below, the Java keywords are highlighted in bold. package [package_name]; import [other_packages]; public class ClassName { [variables(also known as fields)]; [constructor(s)]; [other methods]; } […]