Yes we can create a instance in another class.
For e.g
final Class A{
int i;
public void fun(){
//Some code
}
}
class B{
int j;
A obj = new A();
public void gun(){
//Some code
}
}
09 Feb 2023, 01:59
Learn java programming through quizzes and videos
Show more
We use cookies to improve your browsing experience.
By clicking “Accept all”, you agree to the cookie policy.