Skip to main content

Posts

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...

How to run java program using while loop

 Java program how to print Happy New Year in 10 times(using while loop) java buzzwords static keyword in java The AI ​​Revolution- Malayalam article step by step explanation Before writing Java code Install Jdk on your system and Set the path properly. Then type the Java code in the notepad and save it as a class name with the .java extension. Select the file type 'all file' while saving. Open cmd, Change the directory where the file is saved, using the cd command. Type javac class name.java then press the enter key, If you type java and give the class name, If there is no error in the program, the output will be generated. Observe the directory change using the cd command. Give the class name and watch it compile and run. How to run java program in notepad and cmd Where to code in Java and how it works? method 1 A text editor is required to write Java code The code can be run using the command prompt method 2  using an integrated development environment (IDE), such as Eclips...

Java Left Triangle Pattern Program Using 'for loop'

 Java Left Triangle Pattern Program Using 'for loop' Java Left Triangle Pattern Program-   more - programs Using for loop  Left triangle pattern program class Pattern   {     public static void main(String args[])    {     //i for rows and j for columns       //row denotes the number of rows you want to print   int i, j, row = 20;        //Outer loop work for rows   for (i=0; i<row; i++)    {   //inner loop work for space       for (j=2*(row-i); j>=0; j--)     for (j=2*(row-i); j>=0; j--)          {   //prints space between two stars       System.out.print(" ");    }    //inner loop for columns   for (j=0; j<=i; j++ )    {    //prints star  ...

Java Right Triangle Pattern Program Using for loop

 Java Right Triangle Pattern Program Using for loop  Java Right Triangle Pattern Program Using for loop  class Patter{ public static void main(String args[]) {   //i for rows and j for columns       //row denotes the number of rows you want to print   int i, j, row=6;    //outer loop for rows   for(i=0; i<row; i++)    {    //inner loop for columns   for(j=0; j<=i; j++)    {    //prints stars    System.out.print("* ");    }    //throws the cursor in a new line after printing each line   System.out.println();   } } }

Java program adding two number

 Java program adding two number using variable and without variable In this java program , two numbers directly give print function then added, second method create variable gives the number then add A java program to add two integer number class Add{ public static void main(String a[]) { System.out.println(10+20);//without variable creation System.out.println(); int num1=10;//num1 is variable, int data type, 10 value int num2=20;//integer number 20 assigne variable num2 System.out.println(num1+num2);//adding two number with variable creation }           } A java program to add two integer number using eclipse IDE observe the program and its output carefully

java programming questions and answers

 java coding test questions and answers Java Objective Type Q&A Object type Q&A     1. The first version of Java was actually named Oak      2. A single line statement in Java ends with semicolon     3. The execution of Java application begin at main method 4. Features of java is called as Java Buzzwords   oops concept & key word part object are combination of code and data that are treated as a single unit In objects, the behavior of the real-world entities is represented by method  In objects, data members/data elements define the state of an object Class is a model or blue -print from which an object is created. Binding the data to methods of an object is called encapsulation Polymorphism provides the mechanism of ‘one name but different implementations’ A class method is used to assign values to private instance variables of a class Inheritance enable software reusability w...

Java program adding two number using command line argument

  Java program adding two number using command line argument Here you can see that the answer is created when the input is passed at run time. Reading the command line argument note will clear your doubts A java program to add two integer number using command line class AddCommandLine { public static void main(String args[]) { int num1=Integer.parseInt(args[0]); int num2=Integer.parseInt(args[1]); System.out.println("Answer is    :"+(num1+num2)); } }

Files&Input Output(I/O) Stream in Java(scanner class)

Files And Input Output(I/O) Stream in Java Very Short And Important Notes        Input and output(I/O) are the most commonly used operations in any program.Reading data from the keyboard and writing data on the monitor form the basic input and output operation. Java uses streams to handle data input and output.Input streams act as sources of data and output streams act as destinations of data.The java.io package defines various classes and methods for reading and writing files and handling data streams. Java i/o stream Stream is a logical connection between java application and file. Stream is nothing but a byte of data.There are three i/o stream S ystem.in —> Used to read the data from the keyboard S ystem.out —> Used to display the data on screen S ystem.err —> Display the error message Every class will be available in packages. so we have to import  the package before using those classes in our program .All these i/o streams are availa...