Difference between for loop and For-each loop in java?

The difference between for loop and For-each loop are as follows..  for loop For-each loop  1.for loop is a feature added from version.  1. For-each loop is a new feature added from jdk 1.5 version.  2.for loop is used to performed repeatation process until and unless condition become false. 2.For-each loop is used to modify … Read more

Difference between Array and Collection?

The difference between Array and Collection are as follows.. Array Collection  1.Array is a collection of similar Homogeneous element.  1.Collection is collection of homogeneous and hetrogeneous element.  2.Array is a fixed size.  2.Collection is dynamic growable.  3.Chance of memory wastage.  3.No memory wastage problem.  4.Store data type as well as object type.  4.Stores only object … Read more

Object Oriented and Procedure Oriented Programming ?

Object oriented and procedure oriented programming are given below: The difference between Object oriented and Procedure oriented Programming are as follows.. Object Oriented Programming (OOPs) Procedure oriented Programming (POPs)  1. Data is more Secure in Object Oriented Programming language.  1.Data is less Secure in Procedure Oriented Programming Language. 2.In Object Oriented Programming , Data and Function are … Read more

Java program to print Multiplication Table

Java program to print Multiplication Table 1. Java program to print Multiplication Table(1 to 15) using for loop: Program: import java.io.*; import java.util.*; class Table { public static void main(String args[]) { for(int i=1;i<=15;i++) { for(int j=1;j<=10;j++) { System.out.print(+i+”*”+j+”=”+(i*j)); System.out.print(“\t”); } System.out.println(“\n”); } } }  Output: 1*1=1 2*1=2 3*1=3 ……………. 15*1=15 1*2=2 2*2=4 3*2=6 ……………. … Read more

Java program to accept character as input and check whether it is Capital letter, Small Letter, or symbol

Java program to accept character as input and check whether it is Capital letter, Small Letter, or symbol 1. Java program to accept character as input and check whether it is Capital letter, Small Letter, or number using if- else if statement: Program: import java.io.*; import java.util.*; class Symbol { public static void main(String args[]) … Read more

Java program to check character is vowel or consonant

Java program to check character is vowel or consonant  1. Java program to check character is vowel or consonant using if- else if statement: Program: import java.io.*; import java.util.*; class Vovels { public static void main(String args[]) { Scanner sc=new Scanner(System.in); System.out.println(“Enter any Character”); char xy=sc.next( ).charAt(0); { if(xy==’a’||xy==’e’||xy==’i’||xy==’o’||xy==’u’||xy==’A’||xy==’E’||xy==’I’||xy==’O’|| xy==’U’) { System.out.println(xy+” is Vowel”); } else … Read more

Java program to check Leap year or not

 Java program to check Leap year or not 1. Java program to check Leap year or not using if-else statement: Program: import java.io.*; import java.util.*; class LeapYear { public static void main(String args[]) { Scanner sc=new Scanner(System.in); System.out.println(“Enter the year”); int yr=sc.nextInt(); if((yr%400==0)||(yr%100!=0 && yr%4==0)) { System.out.println(yr+ ” is a leap year”); } else { System.out.println(yr+” … Read more