Skip to main content

Posts

Showing posts from January, 2023

static keyword in java short explanation

  Static variable-static method and static block static keyword  The static keyword in Java is mainly used for memory management. When a member is declared static, it can be accessed directly.To create a static member, the static keyword is used before its declaration.Block, variable, method and classes can use static keyword. java buzzwords explanation static variable and static method in java have different types of variables are available local,instance and static variable In a class global variables are declared using the static keyword Definition of object —>An object is programming entity and class is collection of object Every class will be having variables and methods If the variable declare as a static these static variable can be access into two ways 1 directly access—>If our program is in a single class You can directly access the variable 2 with the help of class name—->If your program is in multiple classes You can access the variable with the help of cla...

Java variable program using notepad CMD output

 Java  variable program using notepad CMD output Different type variabe diclaration and printing program class Variable{ static  int age=25;  //static variable int ID=498;  // instance variable  public static void main(String args[]){ String name="Habiba";    // local variable System.out.println(name);  // Habiba printed System.out.println(age);    // 25 printed Variable object1=new Variable(); // object creation System.out.println(object1.ID);  // 498printed } }

Java short note in constructor-Java programming

Constructor in java short note with example program constructor constructor is a method with the same name as the class name that is generally used to Initialize the instance variable and does not return any value, not even void. Before understanding what is constructor , let's see how object is created Syntax of object creation Classname objectname=new constructor(); here new  is java keyword  used to create an object (instance) constructor are called automatically when a new object is created when an object is created in java using the keyword new following things happen: Memory is allocated for new objects Instance variables of the objects are initialized, either to their initial values or to default values(0 for number,null for objects) A constructor is invoked Constructor() is used to initialize the object Rules to be followed creation of constructor constructor name must be equal to class names constructor does not have return type It is  entirely different from a...

BufferedReaderClass in Java(I/O Stream)

BufferedReaderClass in Java(I/O Stream) BufferedReaderClass in Java(I/O Stream) Using java BufferedReader class we can to read input from either keyboard or existing file.This BufferedReader class is used to read the character from charecter input stream. There are three input stream in java (IO stream) System.in,System.out,system.err InputStreamReader → read bytes and decoded to charecter set File Reader —> used to read data from existing file This is  done with the help of  system.in(standard I/Ostream) The buffered data is read using the BufferedReader class m ethod Each class has many methods.To invoke this method object must be created. When reading data using filereader class, if the file does not exist, an exception is raised. So when using the bufferedreader class, the program should include IOException BufferedReader class available in io package.If you want to implement methods in the BufferedReader class, you have to import io package Methods available in buffe...