Thursday, January 2, 2020

BSc 2nd year, List of Java Program






     1.       Write a program in Java to print Namaste Bharat.
     2.       Write a program in Java to get user input from argument list and using scan classes.
     3.       Write program to print count from 1 to 100.
     4.       Write a program to print Fibonacci series using for loop
     5.       Write program in java to implement method overloading.
     6.       Write program in java to implement constructor in java.
     7.       Write program in java to different method of String.
     8.       Write program in java to wrapper classes.
     9.       Write program in java to Static member and static functions.
    10.   Write a program in java to Addition of 2 X 2 matrix using array.
    11.   Write a program in java to implement following inheritance
A)     Single Level Inheritance
B)      Multilevel Inheritance
C)      Hierarchical Inheritance.
     12.   Write program in java to implement final class, final variable and final method.
     13.   Write program in java to implement Abstract class, abstract variable and abstract method.
     14.   Write program to create interface, inherit interface and implement interface,.
     15.   Write a program in java to implement Applet program.
     16.   Write a program in java to implement multi-threading.



Practice Programs
1. Sample 1

public class Sample_BScII
{
      public static void main(String[] args)
        {
            System.out.println(" First Program in Java");
        }
 }

2. Sample 2

public class Sample_2
 {
    public static void main(String args[])
    {
      System.out.println(24+26);
    }

}

3. Sample 3
public class Sample_3
{
    public static void main(String[] args)
    {
        float first = 1.5f;
        float second = 2.0f;
        float product = first * second;
        System.out.println("The product is: " + product);
    }
 }

4. Sample 4 

public class Largest
 {
    public static void main(String[] args)
     {
        double n1 = -4.5, n2 = 3.9, n3 = 2.5;
    
       if( n1 >= n2 && n1 >= n3)
               System.out.println(n1 + " is the largest number.");
        else if (n2 >= n1 && n2 >= n3)
               System.out.println(n2 + " is the largest number.");
        else
             System.out.println(n3 + " is the largest number.");
    }
}

5. Sample 5 
class Sample_5
{
  int i;
}

class Main
{
   public static void main(String args[])
   {
     Test t;
     System.out.println(t.i);
   }


6. Sample 6  

class Sample_6
{
  int i;
}
class Main {
  public static void main(String args[])
  {
      Test t = new Test();
      System.out.println(t.i);
   }
}


7. 


class A
{
    static int first;
    static String second;
    static
     {
        System.out.println(1);
        first = 100;
     }

    static
    {
        System.out.println(2);
        second = "SECOND";
    }
}
public class Sample_7
{
    static
    {
        System.out.println(3);
    }

    public static void main(String[] args)
    {
        System.out.println(5);
        System.out.println(A.first);
        System.out.println(A.second);
    }
}

1.       
S        

No comments:

Post a Comment

Financial Year Oracle PLSQL Program

 CREATE OR REPLACE function FINANCIAL_YEAR(p_date DATE) return varchar2 IS    v_first     varchar2(4);    v_second    varchar2(4);    v_year...