Posts

Showing posts from March, 2023

OOP IN JAVA(MERHOD OVERRIDING AND " super" KEYWORD)

Image
  M ETHOD OVERRIDING  A subclass inherits all variables and methods from its super class. we can modify the superclass methods in subclass with the same method  as defined in superclass. Some it is very important to modify superclass method in subclass to change or customize the implementation of superclass method.  N ormally ; its means method overriding is a changing the body of the method coming from a superclass to a sub class.  note :  especial thing is an  overriding , only the method related to the object is always executed  and  also it can be used   for runtime polymorphism class  Vehicle{      void  run(){     System.out.println( "Vehicle is running" );                          }   }   //Creating a  sub (child) class       class  Bike  extends  Vehic...

OOP IN JAVA ( METHOD OVERLOADING : STATIC AND INHERITANCE)

Image
  STATIC I n Java, we must first build an instance of the class before can access it. On the other hand, there may be circumstances where want to access class without setting up any variables. In some circumstances, J ava's "static" keyword can be used. Class must be declared static if we wish to access them without generating a class instance. and also static isn't a  Access Modifier. But it is used as a modifier and can directly access main method to if it is of static type. If the variable or method we create inside the class is kept with the static modifier, we can use the variable or method anywhere in the class.  EX :-                package com. dataflair . statickeyword ; public class StaticBlock { static String sentence; static int number; static { sentence = "Welcome to DataFlair" ; number = 69 ; } public static void main ( String args []) { System. out . println ( se...

OOP IN JAVA ( METHOD OVERLOADING)

Image
  M ethod Overloading  Method overloading is a feature of Java in which a class has more than one method of the same name and their parameters are different.” In other words, we can say that Method overloading is a concept of Java in which we can create multiple methods of the same name in the same class, and all methods work in different ways. When more than one method of the same name is created in a Class, this type of method is called the "Overloaded Method". A nd also, you have to perform the addition of give numbers but there can be so many numbers of arguments (say either 2 or 3 arguments for simplicity)   In order to accomplish the task, you can create methods void h1 (int, int)  and                               void h1 (int, int, int)  for two and three parameters respectively. However, other programmers, as well as you in the  future may get confused as the behav...

OOP IN JAVA (PARAMETERS AND ARGUMENT/ CONSTRUCTOR)

Image
  Parameters and Argument  The values that are declared within a function when the function is called are known as an argument. Whereas the variables that are defined when the function is declared are known as a parameter. When a function is called, the values that are passed in the call are called arguments. While the variables that are written at the time of the function prototype and the definition of the function are called java parameters. Java arguments are used in the function call statement to send values from the calling function to the called function while Java parameters are used in the function header of the called function to receive the value from the arguments. During the time of call, each argument is always assigned to the parameter in the function definition. While parameters are local variables that are assigned a value of the arguments when the function is called. Java arguments are also known as actual parameters. While the parameters are also known as fo...

OOP IN JAVA(OBJECT CREATION AND DATA TYPES)

Image
Java is a oop concept based programmer language.Actually it's main strongest or most powerful part is OBJECT . Do you know whit is an object, object is a combination of Properties and behaviors. Now, H ow to creat OBJECT Object Creation I n Java The object is a foundation of an OOPs language,and  Java, we can't generate any program without creating an object. They are 2 different way to create an object in Java that we will discuss in this section, and also now I explain how to create an object in Java. java, 4 points to create an object. Using class object name Using Variable Using new Keyword  Using clone() method.     And Mainly 2 different type to creat object in java                     human cl = new Human (); & human cl; cl = new human () ; Note : An object can be generated from java only if there is a class. Only a class can be converted to an object. 2 DATA TYPES  Data Types in Java ...

OBJECT ORIENTED PROGRAMMING IN JAVA (STANDARDS / .OPERARTORS/ CLASS AND OBJECT)

Image
The Java Programming Language is based on an OOP Methodology and that has different kinds of point  such as called Java Class hierarchy  Object Class method Variable Do you Know Standards of java? So , above I mentioned java programming language is an OOP based language and its  standards  are Combination with Variables, Class, and method  Now, I will tell: how to identify these standers; C ar - class First letter is Uppercase of the word It's Called  " Class ". c ar - variable First letter is Lowercase of the word it's called " Variable " c ar () -method First letter is a lower Case and after the word with Parameters it's called " Method ". Then Now, I explain: H ow to create java Print Statement             System is a Class ,out is a variable and print () is a method. above mentioned statement use to the Dot Operator ( its use for the Calling) ("Hello World") is a print part and important thing is end of...