Core Java Technical Test on Class and Object Elements

Core Java Technical Test: This Core Java Technical Test on Class and Object Elements  page is providing SCJP or OCJP certification level questions to test your java programming skills and helpful to clear all the technical interviews easily. This test is including the concept of class members and Object members.


1. What is the output of following Code?
class Variables
{
static int a = 10 ;
public static void main(String[] args)
{
int a = 20 ;
System.out.println(Variables.a);
System.out.println(a);
}
}

 
 
 
 

2. What is the output of following Code?
class Test
{
static int a = 50 ;
public static void main(String[] args)
{
System.out.println(Test.fun()+Test.a);
}
static int fun()
{
Test.a = Test.a +100;
return Test.a;
}
}

 
 
 
 

3. What is the output of following Code?
class Variables
{
static String s ;
public static void main(String[] args)
{
System.out.println(s);
}
}

 
 
 
 

4. What is the output of following Code?
class Variables
{
public static void main(String[] args)
{
int a ;
System.out.println(Variables.a);
}
}

 
 
 
 

5. What is the output of following Code?
class Test
{
static
{
Test .a = Test .fun();
}
static int a = 70 ;
public static void main(String[] args)
{
System.out.println(Test .a);
}
static
{
Test .a = Test .a+Test .fun();
}
static int fun()
{
Test .a = 50;
return Test .fun1();
}
static int fun1()
{
System.out.println(Test .a);
return Test .a+30;
}
}

 
 
 
 

6. What is the output of following Code?
class Variables
{
static
{
System.out.println(a);
}
static int a = 10 ;
}

 
 
 
 

7. What is the output of following Code?
class Variables
{
int a = 10 ;
public static void main(String[] args)
{
Test obj = new Test(20);
System.out.println(obj.a);
}
}

 
 
 
 

8. What is the output of following Code?
class Test
{
int a ;
{
System.out.println(a);
System.out.println(this.a);
}
public static void main(String[] args)
{
new Test();
}
}

 
 
 
 

9. What is the output of following Code?
class Test
{
int a ;
{
System.out.println(a);
}
public static void main(String[] args)
{
Test obj = new Test();
System.out.println(obj.a);
}
Test()
{
a = 10 ;
}
}

 
 
 
 

10. What is the output of following Code?
class Variables
{
public static void main(String[] args)
{
System.out.println(a);
}
static int a = 10 ;
}

 
 
 
 

Question 1 of 10

Share this