1. Program to Display String Literal
class Display
{
public static void main( String args[ ] )
{
System.out.println("Let us learn JAVA." );
}
}
2. Program to Explain Different types of Comments in Java Program
/*
This is a simple Java program.
Call this file "Comments.java".
*/
class Comments
{
// Your program begins with a call to main().
public static void main( String args[ ] )
{
System.out.println("BIIT Computer Education.");
}
}
3. Program to Find Area of Circle
class AreaCircle
{
public static void main( String args[ ] )
{
double rad;
final double PI = 3.14159;
rad = 10.0;
double area = PI * rad * rad;
System.out.print( "\n Area of Circle is = " + area );
}
}
4. Program to explain Dynamic Intialization of Variable
class DynInit
{
public static void main( String args[ ] )
{
double a = 3.0, b = 4.0;
// c is dynamically initialized
double c = Math.sqrt(a * a + b * b);
System.out.println("Hypotenuse is " + c);
}
}
5. Program to declare variable at end of class
class DeclareAtEnd
{
public static void main( String args[ ] )
{
msg = "Let's learn JAVA !";
System.out.println("Message : " + msg);
}
static String msg;
}
6.Program to declare static variable at end of class.
class DeclareAtEnd1
{
public static void main( String args[ ] )
{
DeclareAtEnd1 ob = new DeclareAtEnd1();
ob.msg = "Let's learn JAVA !";
System.out.println("Message : " + ob.msg);
}
String msg;
}
7. Program to declare and use character variables.
class CharDemo
{
public static void main(String args[ ])
{
char ch1, ch2;
ch1 = 88; // code for X
ch2 = 'Y';
System.out.print("ch1 and ch2 : ");
System.out.println(ch1 + " " + ch2);
ch1++; // increment ch1
System.out.println("ch1 : " + ch1);
}
}
8. Program to declare and use Boolean variable
class BoolTest
{
public static void main(String args[ ])
{
boolean b;
b = false;
System.out.println("b is " + b);
b = true;
System.out.println("b is " + b);
if(b)
System.out.println("This is executed.");
b = false;
if(b)
System.out.println("This is not executed.");
System.out.println("10 > 9 is " + (10 > 9));
}
}
9. Program to use Integer( feature of using underscore is available in jdk 7)
class J7_Literal2
{
public static void main( String args[ ] )
{
long dec = 1234_5678_9876_5432L;
int hex = 0xE_23D5_8C_7;
int bin = 0b1110_0010001111010101_10001100_0111;
System.out.println("Dec number : " + dec);
System.out.println("Hex number : " + hex);
System.out.println("Bin number : " + bin);
}
}
10. Program to explain Lifetime of variable
class LifeTime1
{
public static void main(String args[ ])
{
int i;
for(i = 1; i <= 5; i++)
{
increment();
}
}
private static void increment()
{
int x = 10;
x++;
System.out.println(" " + x );
}
}
11. Program to create and use Constant
class Constant1
{
static final int NUMBER_OF_MONTHS = 12;
static final double PI = (double) 22 / 7;
public static void main( String args[] )
{
System.out.println("NUMBER_OF_MONTHS : " + NUMBER_OF_MONTHS );
System.out.println("PI : " + PI );
}
}
12. Program to create public Constant and use it
class MyConstant
{
public static final int NUMBER_OF_MONTHS = 12;
public static final double PI = (double) 22 / 7;
}
class Constant2
{
public static void main( String args[ ] )
{
System.out.println("NUMBER_OF_MONTHS : " + MyConstant.NUMBER_OF_MONTHS );
System.out.println("PI : " + MyConstant.PI );
}
}
13. Program to Read data From keyboard using Scanner Class
class Input1
{
public static void main( String args[ ] )
{
Scanner sc = new Scanner( System.in );
int n;
System.out.print( "Enter a Number : ");
n = sc.nextInt();
System.out.println( "The given number : " + n );
}
}
14. Program to read data from keyboard using Console class.
import java.io.*;
class Input2
{
public static void main( String args[ ] )
{
Console cn = System.console();
int n;
System.out.print( "Enter a Number : ");
n = Integer.parseInt( cn.readLine() );
System.out.println( "The given number : " + n );
}
}
class Display
{
public static void main( String args[ ] )
{
System.out.println("Let us learn JAVA." );
}
}
2. Program to Explain Different types of Comments in Java Program
/*
This is a simple Java program.
Call this file "Comments.java".
*/
class Comments
{
// Your program begins with a call to main().
public static void main( String args[ ] )
{
System.out.println("BIIT Computer Education.");
}
}
3. Program to Find Area of Circle
class AreaCircle
{
public static void main( String args[ ] )
{
double rad;
final double PI = 3.14159;
rad = 10.0;
double area = PI * rad * rad;
System.out.print( "\n Area of Circle is = " + area );
}
}
4. Program to explain Dynamic Intialization of Variable
class DynInit
{
public static void main( String args[ ] )
{
double a = 3.0, b = 4.0;
// c is dynamically initialized
double c = Math.sqrt(a * a + b * b);
System.out.println("Hypotenuse is " + c);
}
}
5. Program to declare variable at end of class
class DeclareAtEnd
{
public static void main( String args[ ] )
{
msg = "Let's learn JAVA !";
System.out.println("Message : " + msg);
}
static String msg;
}
6.Program to declare static variable at end of class.
class DeclareAtEnd1
{
public static void main( String args[ ] )
{
DeclareAtEnd1 ob = new DeclareAtEnd1();
ob.msg = "Let's learn JAVA !";
System.out.println("Message : " + ob.msg);
}
String msg;
}
7. Program to declare and use character variables.
class CharDemo
{
public static void main(String args[ ])
{
char ch1, ch2;
ch1 = 88; // code for X
ch2 = 'Y';
System.out.print("ch1 and ch2 : ");
System.out.println(ch1 + " " + ch2);
ch1++; // increment ch1
System.out.println("ch1 : " + ch1);
}
}
8. Program to declare and use Boolean variable
class BoolTest
{
public static void main(String args[ ])
{
boolean b;
b = false;
System.out.println("b is " + b);
b = true;
System.out.println("b is " + b);
if(b)
System.out.println("This is executed.");
b = false;
if(b)
System.out.println("This is not executed.");
System.out.println("10 > 9 is " + (10 > 9));
}
}
9. Program to use Integer( feature of using underscore is available in jdk 7)
class J7_Literal2
{
public static void main( String args[ ] )
{
long dec = 1234_5678_9876_5432L;
int hex = 0xE_23D5_8C_7;
int bin = 0b1110_0010001111010101_10001100_0111;
System.out.println("Dec number : " + dec);
System.out.println("Hex number : " + hex);
System.out.println("Bin number : " + bin);
}
}
10. Program to explain Lifetime of variable
class LifeTime1
{
public static void main(String args[ ])
{
int i;
for(i = 1; i <= 5; i++)
{
increment();
}
}
private static void increment()
{
int x = 10;
x++;
System.out.println(" " + x );
}
}
11. Program to create and use Constant
class Constant1
{
static final int NUMBER_OF_MONTHS = 12;
static final double PI = (double) 22 / 7;
public static void main( String args[] )
{
System.out.println("NUMBER_OF_MONTHS : " + NUMBER_OF_MONTHS );
System.out.println("PI : " + PI );
}
}
12. Program to create public Constant and use it
class MyConstant
{
public static final int NUMBER_OF_MONTHS = 12;
public static final double PI = (double) 22 / 7;
}
class Constant2
{
public static void main( String args[ ] )
{
System.out.println("NUMBER_OF_MONTHS : " + MyConstant.NUMBER_OF_MONTHS );
System.out.println("PI : " + MyConstant.PI );
}
}
13. Program to Read data From keyboard using Scanner Class
class Input1
{
public static void main( String args[ ] )
{
Scanner sc = new Scanner( System.in );
int n;
System.out.print( "Enter a Number : ");
n = sc.nextInt();
System.out.println( "The given number : " + n );
}
}
14. Program to read data from keyboard using Console class.
import java.io.*;
class Input2
{
public static void main( String args[ ] )
{
Console cn = System.console();
int n;
System.out.print( "Enter a Number : ");
n = Integer.parseInt( cn.readLine() );
System.out.println( "The given number : " + n );
}
}
As a biggner in java programming its really help to me. Thanks a lot! You made a new blog entry to answer my question; I really appreciate your time and effort.
ReplyDeletebest java training in chennai |
Core java training in chennai
It is better to engaged ourselves in activities we like. I liked the post. Thanks for sharing.
ReplyDeleteSelenium training in Chennai
Selenium training in Bangalore
Selenium training in Pune
Selenium Online training
I am really very happy to find this particular site. I just wanted to say thank you for this huge read!! I absolutely enjoying every petite bit of it and I have you bookmarked to test out new substance you post.
ReplyDeletepython Training in Pune
python Training in Chennai
python Training in Bangalore
Hey Nice Blog!! Thanks For Sharing!!!Wonderful blog & good post.Its really helpful for me, waiting for a more new post. Keep Blogging!
ReplyDeletebest java training in coimbatore
php training in coimbatore
Nice post. I was checking constantly this blog and I am impressed! Extremely helpful information specially the last part I care for such info a lot. I was seeking this particular information for a very long time. Thank you and good luck.
ReplyDelete北美Java代写
Good blog
ReplyDeleteFor data science training in Bangalore Visit:
Data Science training in bangalore
Excellent post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
ReplyDeleteDevOps Training | Certification in Chennai | DevOps Training | Certification in anna nagar | DevOps Training | Certification in omr | DevOps Training | Certification in porur | DevOps Training | Certification in tambaram | DevOps Training | Certification in velachery
This blog is the general information for the feature. You got a good work for these blog.We have a developing our creative content of this mind.thanks lot!!
ReplyDeleteandroid training in chennai
android online training in chennai
android training in bangalore
android training in hyderabad
android Training in coimbatore
android training
android online training
It was wonerful reading your conent. Thankyou very much. # BOOST Your GOOGLE RANKING.It’s Your Time To Be On #1st Page
ReplyDeleteOur Motive is not just to create links but to get them indexed as will
Increase Domain Authority (DA).We’re on a mission to increase DA PA of your domain
High Quality Backlink Building Service
1000 Backlink at cheapest
50 High Quality Backlinks for just 50 INR
2000 Backlink at cheapest
5000 Backlink at cheapest
ReplyDeleteThis post is so interactive and informative.keep update more information...
RPA Training in Velachery
RPA Training in Chennai
This post is so interactive and informative.keep update more information...
ReplyDeleteGerman Classes in Tambaram
German Classes in chennai