Share on Google+Share on Google+

SCJP Module-1 Question-16

The given program tests your underspending of packages in java and also checks that how to import classes in Java.

Given a sample code:

1 package roseindia;

2 public class ClassA {

3 public static void doSomething() {
4 System.out.println("do something");

5 // Place the statement here

6 public class ClassB {
7 public static void main(String args[]) {
8 ClassA.doSomething();

What statement you place at line number 5 for successful compilation and execution of above code?

(1) import roseindia.*;
(2) import roseindia.ClassA;
(3) import roseindia.ClassA.doSomething.*;
(4) import ClassA;


(1) or (2)


Place statement (1) or (2) both allow the ClassA method to be called from ClassB.


Posted on: July 8, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.


Advertisement null