Archive for the ‘Java Programs’ Category

import java.util.*;
import java.io.*;
class caesar
{
public static void main(String k[])
{
int c;
System.out.println(“ENTER PLAIN TXT :”);
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
s=s.toLowerCase();
for(int i=0;i<s.length();i++)
{
c=s.charAt(i);
c=c+3;
if(c>122)
{
c=c%122;
c=c+96;
}

System.out.println((char)c);
}

}
}

IP-Lookup in Java.

Posted: April 13, 2012 in Java Programs

import java.net.*;

import java.util.*;

class addresscheck { public static void main (String args[])
{
try {
Scanner sc=new Scanner(System.in);
System.out.println(“ENTER IP ADDRESS “);
String ip=sc.nextLine();

InetAddress address = InetAddress.getByName(ip); System.out.println(address);
}
catch (UnknownHostException e)
{
System.out.println(“Could not find domain_name”);
}
}
}

import java.net.*;
import java.util.*;
class ipcheck
{
public static void main(String g[])
{
try {
Scanner sc=new Scanner(System.in);
System.out.println(“ENTER ADDRESS “);
String add=sc.nextLine();
InetAddress address = InetAddress.getByName(add);
System.out.println(address);
}
catch (UnknownHostException e) {
System.out.println(“Could not find the address”);
}
}
}

 

import java.util.*;
class StackDemo {
static void showpush(Stack st, int a) {
st.push(new Integer(a));
System.out.println(“push(” + a + “)”);
System.out.println(“stack: ” + st);
}
static void showpop(Stack st) {
System.out.print(“pop -> “);
Integer a = (Integer) st.pop();
System.out.println(a);
System.out.println(“stack: ” + st);
}
public static void main(String args[]) {
Stack st = new Stack();
System.out.println(“stack: ” + st);
showpush(st, 42);
showpush(st, 66);
showpush(st, 99);
showpop(st);
showpop(st);
showpop(st);
try {
showpop(st);
} catch (EmptyStackException e) {
System.out.println(“empty stack”);
}
}
}

Inheritance in Interface

Posted: March 23, 2012 in Java Programs

interface one
{
void show();
}
interface two
{
void display();
}
class inherit implements two
{
public void show()
{
System.out.println(“Show method called”);
}
public void display()
{
System.out.println(“Display method called”);
}
}
class inter2
{
public static void main(String g[])
{
inherit i=new inherit();
i.show();
i.display();
}
}

Interface

Posted: March 23, 2012 in Java Programs

interface display
{
void show();
}
class showing implements display
{
public void show()
{
System.out.println(“Show method is being called”);
}
}
class inter1
{
public static void main (String g[])
{
showing i=new showing();
i.show();
}
}