The class which inherits the properties of others is known as subclass (derived class, child class) and the class whose properties are inherited is known as superclass (base class, parent class). extends Keyword The extends is a Java keyword, which is used in inheritance process of Java. It is a keyword that indicates the parent […]
Java
Java Overriding
In this post, we will learn the OOP of Java overriding means to override the functionality of an existing method. A subclass can define a behavior that’s specific to the subclass type, meaning that a subclass can implement a parent class method based on its requirement. This is called Overriding. Example: class Animal { public […]
Java – Inner classes
Java supports nesting classes; a class can be a member of another class. Creating an inner class is quite simple. Just write a class within a class. Unlike a class, an inner class can be private. Once you declare an inner class private, it cannot be accessed from an : Nested Classes In java have […]
Java File and I/O
java.io packager provides many data such as primitives, object, localized characters, etc. Stream Sequence of data is called stream. There are two types of Streams: InPutStream: The InputStream is used to read data from a source. OutPutStream: The OutputStream is used for writing data to a destination. Byte Streams It uses byte streams to perform […]
Java Methods
A method is a set of statements to perform an operation, methods are also known as procedures or functions. Creating Method following example to explain the syntax of a method: Syntax: public static int methodName(int x, int y) { // body } Here, public static − modifier int − return type methodName − name of […]
Java – Arrays
An array is a collection of variables of the same type. When you need to store a list of values, such as numbers. You can store them in an array, instead of declaring separate variables for each number. int[ ] arr = new int[4]; The above code is 4 array. In an array, the elements […]
Java Strings Class
Strings are a sequence of characters. For example: String greeting = “Hello Java!”; compiler creates a String object with its value in this case, “Hello Java!’. The String class has 11 constructors that allow you to provide the initial value of the string using array of characters. Example: public class StringDemo { public static void […]
Java Numbers Class
Numbers are primitive data types such as int, float, long, double. Example: int a = 2000; float acg = 11.18; double mask = 0acf; Java give wrapper classes. All the wrapper classes (Integer, Long, Byte, Double, Float, Short) are subclasses of the abstract class Number. Following is an example of setting1 and setting2. Example: public […]
Java Operators
Java – Operators Operators are used to perform operations on variables and values/multiple conditions. JAVA divides the operators in the following groups: Arithmetic operators Assignment operators Comparison operators The Bitwise Operators Logical operators Arithmetic Operators JAVA arithmetic operators are used with numeric values to perform common arithmetical operations, such as addition, subtraction, multiplication etc. Operator […]
Java Character Class
In this post, we discuss the character class in java. Example: char ch = ‘x’; // Unicode for uppercase Greek omega character char uniChar = ‘\u039A’; // an array of chars char[] charArray ={ ‘x’, ‘y’, ‘z’ }; Java provides wrapper class Character for primitive data type char. You can create a Character object with […]