Friday , December 13 2019

Java

JAVA #28 Generics in Java

Generics in Java In a Java, generics enable types (classes and interfaces) to be parameters when defining classes, interfaces and methods. Much like the more familiar formal parameters used in method declarations, type parameters provide a way for you to re-use the same code with different inputs. The difference is …

Read More »

JAVA #27 Object Type in Java

Object Type in Java An object is a class instance or an array. The reference values (often just references) are pointers to these objects, and a special null reference, which refers to no object. A class instance is explicitly created by a class instance creation expression . An array is …

Read More »

JAVA #26 Interfaces in Java

Interface in Java As you’ve already learned, objects define their interaction with the outside world through the methods that they expose. Methods form the object’s interface with the outside world; the buttons on the front of your television set, for example, are the interface between you and the electrical wiring on the …

Read More »

JAVA #25 – Abstract Methods in Java

Abstract Methods An abstract method is a method that is declared without an implementation (without braces, and followed by a semicolon). abstract class GraphicObject { int x, y; ... void moveTo(int newX, int newY) { ... } abstract void draw(); abstract void resize(); } Each nonabstract subclass of GraphicObject, such …

Read More »

JAVA #24 – Abstract Classes in Java

Abstract Classes An abstract class is a class that is declared abstract—it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed. abstract class GraphicObject { int x, y; ... void moveTo(int newX, int newY) { ... } void draw() { . . …

Read More »

JAVA #23 – Nested Classes and Static Keyword in Java

Nested Classes in Java The Java programming language allows you to define a class within another class. Such a class is called a nested class Nested classes are divided into two categories: static and non-static. Nested classes that are declared static are called static nested classes. Non-static nested classes are called inner classes. Syntax: public …

Read More »

JAVA #22 – Method Overriding in Java

Method-Overriding in Java An instance method in a subclass with the same signature (name, plus the number and the type of its parameters) and return type as an instance method in the superclassoverrides the superclass’s method. Syntax public class animal{// Super class …. } public class mammals extend animal{ //child class …

Read More »