ExamVeda
Login
Home
Constructors and Methods
?

Determine output:
class MyClass{
	int i;
	int j;

	public MyClass(int i, int j){
		this.i = i;
		this.j = j;
	}

	public void call(){
		System.out.print("One");
	}
}

public class Test{
	public static void main(String args[]){
		MyClass m = new MyClass(); //line 1
		m.call(); //line 2
	}
}

Answer & Solution
Correct Answer: Option B
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

5 Comments
Asna
Asna 3 years ago
If no constructor created,then the system check for default constructor; but here parameterized constructor defined,but calling default-so compile time error
Kasturi Moghe
Kasturi Moghe 9 years ago
Here the class defines a parameterized constructor due to which the default constructor is not inserted by jvm.When the new intance is created,it does not get the default constructor resulting in compilation error.
Shravya Yadav
Shravya Yadav 9 years ago
when the compiler doesn't have a default constructor, won't it create a default constructor on its own?
Nitin Thakur
Nitin Thakur 9 years ago
Sai Krishna in line one, while the object is created a compiler, will look for no argument constructor in class but as it is not defined there it will result in compile time error.
Sai Krishna
Sai Krishna 9 years ago
please help with this