Java Tutorial

Write a program in java to demonstrate 3rd use of “this” keyword?

class This3 {                 int a,b;                 public This3(int x,int y)                 {                                 a=x;                                 b=y;                                 //”return this;”…

Read More

Write a program in java to demonstrate 2nd use of “this” keyword?

class This2 {                 int a,b;                 public This2()                 {                                 this(5,7);                                 System.out.println(“Default”);                 }                 public This2(int…

Read More

Write a program in java to demonstrate 1st use of “this” keyword?

class This {                 int a,b;                 public This(int a,int b)                 {                                 this.a=a;                                 this.b=b;                 }                …

Read More

Write a program in java to demonstrate instanceof operator?

Instanceof True class Instance {                 public static void main(String arg[])                 {                                 Instance x=new Instance();                                 System.out.println(x instanceof…

Read More

What will be output of following java program? (Static Interview Question)

class A {                 static                 {                                 System.out.println(“A is Loaded”);                 }                 public A()                 {                                 System.out.println(“A…

Read More

What will be output of following java program? (Static Interview Question)

class StaticBlock {                 int a;                 static     //Static Block                 {                                 System.out.println(“Class StaticBlock is Loaded”);                 }                …

Read More

What will be output of following java program? (Static Interview Question)

class StaticBlock {                 static int a;                 static     //Static Block                 {                                 a=7;                                 System.out.println(“Hello”);                 }                …

Read More

Write a program in java to demonstrate static method and Variable?

class StaticDemo {                 static int a=9;                 int b=7;                 public void display()                 {                                 System.out.println(a);                                 System.out.println(b);…

Read More

Write a program in java to print 1 to 10 without using loop and function?

class Constructor {                 static int a=1;                 public Constructor()                 {                                 if(a<=10)                                 {                                                 System.out.println(a++);                                                 new…

Read More