Home Tutorial Java Scjp Part1 SCJP Module-1 Question-6


Share on Google+Share on Google+
SCJP Module-1 Question-6
Posted on: July 7, 2010 at 12:00 AM
The core Java program given below checks the concepts of Inheritance in core Java and is very useful for SCJP exam also

Given a sample code:

1 abstract class Ball {
2 static void method() {
3 int value = 10;
4 System.out.println("value = " + value);
5 }}

6 class Football extends Ball {

7 public class Sample2 {
8 public static void main(String args[]) {
9 Football a = new Football();
10 a.method1();
11 }}

What will be the result?

(1) Compilation succeeds but cause runtime error
(2) Compilation succeeds and give output 10
(3) Compilation fails because of an error at line 2
(4) Compilation succeeds but give warning message because of line no 10


(2), (4)


This sample code compiles and execute successfully with output 10 but with a warning that "The static method method() from the type ball should be accessed in a static way"


Related Tags for SCJP Module-1 Question-6:

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 7, 2010

Recommend the tutorial

Advertisements Advertisements