Posts

Showing posts from March, 2023

Introducing Java Method Overriding And Super Keyword

Image
Method Overriding Changing the Body of a Method from a Super Class to a Sub Class is "Method Overriding". If subclass (child class) has the same method as declared in the parent class, it is known as  method overriding in Java . In other words, If a subclass provides the specific implementation of the method that has been declared by one of its parent class, it is known as method overriding. Usage of Java Method Overriding Method overriding is used to provide the specific implementation of a method which is already provided by its superclass. Method overriding is used for runtime polymorphism Rules for Java Method Overriding The method must have the same name as in the parent class The method must have the same parameter as in the parent class. There must be an IS-A relationship (inheritance). In Overriding, only the Method related to the Object is always executed. Super Keyword The "Super Keyword" is used to call the constructor of the Super Class from a Sub Class.

Introducing Java Inheritance Concepts

Image
  Inheritance   Java Inheritance (Subclass and Superclass) In Java, it is possible to inherit attributes and methods from one class to another. We group the "inheritance concept" into two categories. subclass  (child) - the class that inherits from another class superclass  (parent) - the class being inherited from To inherit from a class, use the 'extends' keyword. class BMWCar() { tires; engine; lights; doors; break liner; seat; steering wheel; drive() {} reverse() {} break() {} signal light() {} horns() {} } class BMWModernCar() { } Taking the things of one class to another class is called Inheritance. It needs to create a relationship between the two classes. Then the first class is called "Super Class" and the new class is called "Sub Class". GitHub Projects

Introducing Java Method Overloading Concepts

Image
 Method Overloading  Exceeding the size of a method is called Method Overloading. With  method overloading , multiple methods can have the same name with different parameters. class World { void countries(int x) { } void countries(string y) { } | Method Signature Method Overloading concept is used to create the same method again and again in the same class. Method Overloading can be done by using or changing parameters. It is called "Method Signature". Consider the following example, which has two methods that add numbers of different type. Instead of defining two methods that should do the same thing, it is better to overload one. GitHub Projects

Introducing Java Parameters, Arguments And Constructors

Image
Parameters And Arguments Information can be passed to methods as parameter. Parameters act as variables inside the method. Parameters are specified after the method name, inside the parentheses. You can add as many parameters as you want, just separate them with a comma. int        b     =    7; Integer   Variable      V alu e string str = "Java" ; Object? public static voiid main(string[]args){ } void my height(){ } return type methodname void add Numbers(){ int a = 6; int b = 4; int c = a = b; System.out.print(c); } return type - 9 The parameter is there to keep Input and Output. And the Return Type is there to return the Output. Constructor A Constructor is a Method. But this is a special method. 1. The constructor must be created with the same name as the class. 2. There is no return type. Ex:- class Java { Java () { - Constructor } } A constructor in Java is a  special method  that is used to initialize objects. The constructor is called when an object of a class is cre

Introducing Java Object Creation and Data Types

Image
O bject Creation In Java, an object is created from a class. Only a Class can be converted into an Object. Oracle Corporation Company Oracle = new Oracle(); Class Name - Company Variable Name - oracle Assignment - = Object Generate Keyword - new Parameter List variable - () Line End - ; Data Types Primitive Data Types byte - integer char - integer short - integer int - integer long - integer float - floating point double - floating point Integer Float Binary 1/0 True/False Integer Hierarchy 1.Long 2.int 3.short 4.char 5.byte Floating Hierarchy 1.double 2.float int a = 5; integer long b = 7; a+b; (Any Arithmatic Expression) foat c = 7.8; float double d = 9; d-c; long e = 123456; various float f = 789.76; types e+f; Access is possible if the related Primitive Types are of the same type. If the types are different, it cannot be accessed directly.

Introducing Java Object Oriented Programming Concepts

Image
OOPC-Object Oriented Programming Concepts Java Class Heirachy 1. Object 2. Class 3. Method 4. Variable Standards Coding Standards for Classes Usually class name should be noun starting with uppercase letter . 1st Letter Uppercase - C ar 1st Letter Lowercase - c ar Parameter List -           car () Operators Operators are used to perform operations on variables and values. .           Dot Operator =           Assignmental Operator  -  Here the substitution is done. ==        Equalization Operator  -  Here the comparison is made.                                        Class & Object Object An object is an identifiable object with some properties and behavior. Because an object is simply a real-world object, it is easier to understand the concept of objects when we consider real-life examples around us. You will be surrounded by a number of objects with certain characteristics and behaviors. Example:- we can say that 'man' is an object. Its properties are: head, arms, legs et