Category Archives: java

Java Programming: Experiment 2 (codes)

click to download SE IT/ Sem 3/ Rev 2016/ Java Programming/ Experiment 2 (codes) (7z file)

i) Write a java program to demonstrate Constructors, Parameterized Constructors and Constructor Overloading
ii) Write a java program to demonstrate Command Line Arguments
iii) Write a java program to demonstrate String Functions
iv) Write a java program to demonstrate Array and Vectors operations
v) Write a java programs to add n strings in a vector array. Input new string and check whether it is present in the vector. If it is present delete it otherwise add it to the vector.
vi) Write a java programs to test whether the given element is present in the vector
array.
vii) Write a java programs to find frequency of a element in the given Vector array.
viii) Write a java programs to add n strings in a vector array. Input new string and check whether it is present in the vector. If it is present delete it otherwise add it to the vector.
ix) Write menu driven program to implement recursive functions for following tasks.
a) To find GCD and LCM b) To find X Y
c) To print n Fibonacci numbers d) To find reverse of number
e) To 1+2+3+4+……..+(n-1)+n
x) Write the Menu driven program to perform
a) Addition of two matrices of order m*n and p*q
b) Multiplication of two matrices of order m*n and p*q
c) Transpose of matrix of order m*n
d) addition of diagonal and non-diagonal elements

Advertisements

Java Programming: Experiment 1 (codes)

click to download SE IT/ Sem 3/ Rev 2016/ Java Programming/ Experiment 1 (codes) (rar file)

i) Write a Java program to understand how to accept input using Scanner or BufferedReader and print output using System.out.println statement. (ScannerTest.java, BufferedReaderTest.java)
ii) Write a Java program to display the default value of all primitive data types
in Java. (DefValues.java)
iii) Write a Java program that prints all real solutions to the quadratic equation
ax2+bx+c = 0. Read in a, b, c and use the quadratic formula. If the discriminate b2-
4ac is negative, display a message stating that there are no real solutions. (QuadEq.java)
iv) Write a java program to test whether string is palindrome or not (Palindrome.java)
v) Write a java program to count number of alphabets, digits, special symbols,
blank spaces and words from the given sentence. (SentenceContent.java)
vi) Write a java program to count number of vowels and consonants from the given
strings. (VowelsConsonants.java)
vii) Write a Menu driven program in java to implement simple banking application. Application should read the customer name, account number, initial balance, rate of interest, contact number and address field etc. Application should have following
methods.
1. createAccount()
2. deposit()
3. withdraw()
4. computeInterest()
5. displayBalance() (Account.java)
viii) Write a menu driven Java program which will read a number and should implement the following methods
1. factorial()
2. reverse()
3. testArmstrong()
4. testPalindrome()
5. testPrime()
6. fibonacciSeries() (NumericOps.java)
ix) Write a Java program to demonstrate Method overloading. (MethodOverloading.java)

OOPM: java program for fibonacci series

//fibonacci w/o recursion
import java.io.*;

class Fibbo{
public static void main(String args[])
{
int n,x,y,temp;
n = Integer.parseInt(args[0]);
x=0;
y=1;
do{
System.out.print(x + ” “);
temp = x;
x = y;
y = temp + y;
n–;
}while(n>0);
}
}

*********************************************************************

//fibonacci with recursion
import java.io.*;

class Fibbo
{
void fib(int x, int y, int n)
{
int temp;
if(n<=0)
System.out.print(x + ” “);
else
{
System.out.print(x + ” “);
temp = x;
x = y;
y+=temp;
fib(x,y,–n);
}
}
}

class FibboRec{
public static void main(String args[])
{
int n;
n = Integer.parseInt(args[0]);
Fibbo f = new Fibbo();
System.out.print(“Fibonacci series:”);
f.fib(0,1,n);
}
}

OOPM: java program for reverse of number

//reverse of number w/o recursion
import java.io.*;

class Rev{
public static void main(String args[])
{
int n;
n = Integer.parseInt(args[0]);
while(n!=0)
{
System.out.print(n%10);
n/=10;
}
}
}

***********************************************************

//reverse of number with recursion
import java.io.*;

class revNum
{
void rev(int n)
{
if(n<10)
System.out.println(n);
else
{
System.out.print(n%10);
rev(n/10);
}
}
}

class RevRec{
public static void main(String args[])
{
int n;
n = Integer.parseInt(args[0]);
revNum r = new revNum();
System.out.print(“Reverse of number:”);
r.rev(n);
}
}