Skip to main content

Posts

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

Command Line Arguments In Java

Command Line Arguments In Java No input statement needed in the program itself. we can pass the input as an argument while running the program. Sometimes you will want to pass information into a program when you run it. This is accomplished by passing command line arguments to main function. To access the command line arguments inside a java program is quite easy are stored as string in string array passed to main function. Example program of command line arguments in java class CommandLineExample {    public static void main(String args[]) {    System.out.println("\nMy first input is  :"+args[0]);    }    }    Addition of two numbers in java using command line arguments  Example:write a program add two integer number    class AddCommandLine { public static void main(String args[]) { int num1=Integer.parseInt(args[0]); //type cast int num2=Integer.parseInt(args[1]); //type ...

Data Type In Java programming

  Data Type In Java with example program Unlike c++ ,Java is a strongly typed language. Data type is used to declare a variable. Every variable should be declared before using that variable in  the program. A data type defines a set of values and the operation that can be performed on them. There are  two types of data types available in Java. Primitive data type (also known as value type) In primitive data type size is predefined and stored in stack memory  Non Primitive data type(also known as reference data type) Reference data type stored in heap memory this type is not predefined Primitive data type Boolean —> Boolean data type consists of two values true/false,by default it is false Size of Boolean variable is one bit byte  —> very small integer  short —> small integer  int —>  integer number long —> big integer number char —> 0 to 9,a to z(uppercase and lowercase)special symbol    float —> floating numbe...