> But i think it should be A, C Hi!!! I agree. if we have an abstract method in the class, then also the class must be abstract. So we have to remove abstract modifier from method or add abstract modifier to the class. In this way, correct answers are A i C. Have a nice day, Mariusz
Yeah Ranchers, The answer is A and C. A class with abstract method MUST be declared as "abstract". An abstract method/ native method CAN NOT have a body /definition. I guess this clears this issue. Ravindra Mohan.
So I think the right answer is still only C, since the method Test has a body ! If you just remove the abstract modifier from the method declaration of Test it compiler fine. BUT if you add the abstract modifier to the class declaration it won't compile !! Anyone ? Val
If without considering the assumptions, i compile the code, it will give both the class error as well as the method error. So i still think it is A,C
To make the code compile we can do "either" of the below: 1.Remove the method body for Test() and declare the class as abstract. 2. Remove the abstract keyword from Test() method. Correct me if wrong ..
Angela, First, the only error I get by compiling the code is about the body of the abstract Test method, but nothing about the class declaration. I agree with you BUT, in the proposed answers there is no "In the body of the Test method" !!! The only thing about the Test method is about its declaration so considering the given answers, the only correct answer is C, because if you remove the abstract modifier in the declaration of the method Test, it will correct the error given by the compiler !!! Val
I get the below two errors : MyTest.java:1: MyTest should be declared abstract; it does not define Test() in MyTest public class MyTest { ^ MyTest.java:8: abstract methods cannot have a body public abstract void Test() { ^ 2 errors
i think this discussion is more about poor question writing than code. both answers could be seen as correct depending on your viewpoint. everyone picked up on the need for an abstract class declaration and removal of method body, ambiguous questions can drive you mad. kind regards, james.