Question 56 / 297:  Three of the methods are incorrectly declared, which are they?
public abstract class Tester {

public void test1();

public final void test2() {};

public static void test3() {};

public abstract static void test4();

public abstract final void test5();

}

A  test1 , test2 and test4
B  test2 , test4 and test5
C  test1 , test4 and test5
<< First < Previous Next > Last >>
Explanation:

An abstract method in a class can only set its access modifier to public, package scope (no access modifier) or protected. An abstract method cannot be marked static.

A method cannot be abstract and final at the same time.

A non-abstract method (like test1()) must provide an implementation

Note that we are talking about abstract methods in a class, not in an interface.

The are some differences between an abstract method inside a class and inside an interface :

1) In an interface no explicit abstract modifier is needed, because by default all methods are abstract. Which is not the case for an abstract method in a class (must be explicitly marked abstract)

2) An abstract method in an interface cannot be marked protected (only public or no modifier are allowed). In a class, an abstract method can be marked protected

Exam Home Page
Ask
Brenna Fike
Start Quiz
Darlene Paliswat
Start Test
Saylor Foundation
Start Quiz
Madison Christian
Start Quiz
Copy and paste the following HTML code into your website or blog.
<iframe src="https://www.jobilize.com/embed/java-certification-questions" width="600" height="600" frameborder="0" marginwidth="0" marginheight="0" scrolling="yes" style="border:1px solid #CCC; border-width:1px 1px 0; margin-bottom:5px" allowfullscreen webkitallowfullscreen mozallowfullscreen> </iframe>