Book Program
class x
{
int a;
float f;
}
class y extends x
{
double c;
}
class clas
{
public static void main(String arg[])
{
x xx = new x();
y yy = new y();
Class ob;
ob = xx.getClass();
System.out.println("xx is object of type : " + ob.getName());
ob = yy.getClass();
System.out.println("yy is object of type : " + ob.getName());
ob = ob.getSuperclass();
System.out.println("y's superclass is : " + ob.getName());
}
}
class disp
{
public static void main(String a[])
System.out.println(a[i]);
}
}
}
class init
{
public static void main(String[] arg)
{
int k;
int n=!1;
System.out.println(n);
System.out.println(arg[0]);
}
}
class out
{
int i=20;
private int j=30;
public int k =40;
protected int l=50;
public void m()
{
in inn = new in();
inn.inmethod();
}
public void mpu()
{
System.out.println("Pub");
}
public void mpr()
{
System.out.println("Pri");
}
void mde()
{
System.out.println("default");
}
class in
{
int j=10;
public void inmethod()
{
System.out.println("Inner method" + (i+j+k+l));
mpr();
mpu();
mde();
System.out.println("this j"+j);
// m();
}
}
}
class inner
{
public static void main(String arg[])
{
out o = new out();
o.m();
}
}
class math
{
public static void main(String arg[])
{
System.out.println(Math.random());
System.out.println(Math.E);
System.out.println(Math.PI);
System.out.println(4^5);
}
}
class mem
{
public static void main(String arg[])
{
Runtime r = Runtime.getRuntime();
long mem1,mem2;
int i;
Integer in[] = new Integer[1000];
System.out.println("total memory " + r.totalMemory());
mem1 = r.freeMemory();
System.out.println("Free memory " + mem1);
r.gc();
mem1 = r.freeMemory();
System.out.println("Free memory after garbage " + mem1);
for(i=0;i<1000;i++)
in[i] = new Integer(i);
mem2 = r.freeMemory();
System.out.println("Free memory after decl" + mem2);
System.out.println("diff " + (mem1-mem2));
r.gc();
r.gc();
r.gc();
mem2 = r.freeMemory();
System.out.println("Free memory after gc " + mem2);
}
}
class meth
{
public static void p(String s)
{
System.out.println(s);
}
static
{
p("hello");
}
public static void main(String a[])
{
p("hi");
char k='f';
switch(k)
{
case 'f' :
p("true");
break;
case 'a':
p("false");
break;
default :
p("default");
}
}
}
public class priclass
{
public static void main(String a[])
{
a ob1 = new a();
b ob2 = new b();
c ob3 = new c();
}
}
protected class a
{
public int k=33;
}
class b
{
public int j=23;
}
public class c
{
public int i=24;
}
class quest
{
public static void main(String arg[])
{
int i=7,j=8;
int n=(ij) % (i & j) ;
System.out.println(n);
}
}
/* static class s
{
System.out.println("hi");
}
*/
static class statclass
{
public static void main(String arg[])
{
s ss = new s();
}
}
import java.util.*;
class test19
{
public static void main(String g[])
{
Vector v = new Vector();
v.add("Radiant");
v.add("Software");
System.out.println(v.elementAt(0) + v.elementAt(1));
}
}
Sunday, January 6, 2008
Java Example Event Programming
Posted by
Real Time Questions
at
11:12 PM
Labels: Java Example Event Programming-5
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment