About Question enthuware.ocajp.i.v8.2.1493 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
BaxLi007
Posts: 11
Joined: Wed Jun 26, 2019 12:43 pm
Contact:

About Question enthuware.ocajp.i.v8.2.1493 :

Post by BaxLi007 »

As a completion - it is possible to make both methods static in interface and in FooBase...
Or to switch make bar static in Interface and non-static in FooBase

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1493 :

Post by admin »

What happened when you tried it out?
If you like our products and services, please help us by posting your review here.

BaxLi007
Posts: 11
Joined: Wed Jun 26, 2019 12:43 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1493 :

Post by BaxLi007 »

all is compiling successfully ...
// case 1
interface Bar {
static void bar(){};
}
abstract class FooBase {
static public void bar(){} ;
}
public class Test extends FooBase implements Bar {
}

// case 2
interface Bar {
static void bar(){};
}
abstract class FooBase {
abstract public void bar();
}
public class Test extends FooBase implements Bar {
public void bar(){};
}

// case 3
interface Bar {
static void bar(){};
}
abstract class FooBase {
public void bar(){};
}
public class Test extends FooBase implements Bar {
}

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1493 :

Post by admin »

OK, very good. So, what is your question?
If you like our products and services, please help us by posting your review here.

BaxLi007
Posts: 11
Joined: Wed Jun 26, 2019 12:43 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1493 :

Post by BaxLi007 »

Excuse me, I'm wasn't explicit enough. It wasn't a question - it is a completion of the possible correct answers ...

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1493 :

Post by admin »

ok :thumbup:
If you like our products and services, please help us by posting your review here.

rcarinha@hotmail.com
Posts: 4
Joined: Sat May 25, 2019 10:21 am
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1493 :

Post by rcarinha@hotmail.com »

The code will compile correctly, if:

Make the bar method in Bar interface default like this - default void bar() { }

Shouldn't this be the correct answer?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1493 :

Post by admin »

What happened when you tried it out?
If you like our products and services, please help us by posting your review here.

rcarinha@hotmail.com
Posts: 4
Joined: Sat May 25, 2019 10:21 am
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1493 :

Post by rcarinha@hotmail.com »

It happened exactly what I stated above... it compiled correctly:

interface Bar{
default void bar(){};
}

abstract class FooBase{
public static void bar(){
System.out.println("In static bar");
}

}

public class Foo extends FooBase implements Bar{

}

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1493 :

Post by admin »

Are you sure? The code that you have posted doesn't compile.
If you like our products and services, please help us by posting your review here.

rcarinha@hotmail.com
Posts: 4
Joined: Sat May 25, 2019 10:21 am
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1493 :

Post by rcarinha@hotmail.com »

You are correct. It was an issue with IntelliJ. It does not show the compilation error, until I build or execute the code(adding a main method).
My bad! Thanks for the reply!

Post Reply

Who is online

Users browsing this forum: No registered users and 56 guests