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.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.