Core Java Technical Test on Packages

Core Java Technical Test: This Core Java Technical Test on the Packages page is providing SCJP or OCJP certification level questions to test your java programming skills and help to clear all the technical interviews easily. This test is including the concept of Packages in Java.


1. What is the output of following Code ?
class String
{
public static void main(String[] args)
{
System.out.println(“Hello”);
}
}

 

 
 
 
 

2. What is the output of following Code ?
package p1 ;
public class First
{
static()
{
System.out.println(“First”);
}
}

package p2;
import p1.First ;
class Second
{
public static void main(String[] args)
{
new First();
}
}

 
 
 
 

3. What is the output of following Code ?
import java.lang.String ;
package learn ;
class Test
{
public static void main(String[] args)
{
System.out.println(“Package created”);
}
}

 
 
 
 

4. What is the output of following Code ?
package p1 ;
public class First
{
public static int a = 10 ;
}

package p2;
class Second
{
public static void main(String[] args)
{
System.out.println(p1.First.a);
}
}

 
 
 
 

5. What is the output of following Code ?
class Test
{
public static void main(String[] args)
{
java.util.Scanner sc = new java.util.Scanner(System.in);
System.out.println(“Scanner object created”);
}
}

 
 
 
 

6. What is the output of following Code ?
package p1 ;
public class First
{
static
{
System.out.println(“First Loads”);
}
public static void check()
{
System.out.println(“Check”);
}
}

package p2;
import p1.First ;
class Second
{
public static void main(String[] args)
{
First.check();
}
}

 
 
 
 

7. What is the output of following Code ?
class System
{
public static void main(String[] args)
{
System.out.println(“Hello”);
}
}

 
 
 
 

8. What is the output of following Code ?
package p1 ;
public class First
{
public static int a = 100 ;
}

package p2;
class Second
{
public static void main(String[] args)
{
System.out.println(First.a);
}
}

 
 
 
 

9. What is the output of following Code ?
class String
{
public static void main(java.lang.String[] args)
{
System.out.println(“Hello”);
}
}

 
 
 
 

10. What is the output of following Code ?
package p1.p2 ;
public class First
{
public void check()
{
System.out.println(“Hello…..”);
}
}

package p3;
import p1.* ;
class Second
{
public static void main(String[] args)
{
First obj = new First();
obj.check();
}
}

 
 
 
 

Question 1 of 10

Share this