About Question enthuware.ocajp.i.v8.2.1493 :
Moderator: admin
-
- Posts: 11
- Joined: Wed Jun 26, 2019 12:43 pm
- Contact:
About Question enthuware.ocajp.i.v8.2.1493 :
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
Or to switch make bar static in Interface and non-static in FooBase
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1493 :
What happened when you tried it out?
If you like our products and services, please help us by posting your review here.
-
- Posts: 11
- Joined: Wed Jun 26, 2019 12:43 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1493 :
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 {
}
// 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 {
}
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1493 :
OK, very good. So, what is your question?
If you like our products and services, please help us by posting your review here.
-
- Posts: 11
- Joined: Wed Jun 26, 2019 12:43 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1493 :
Excuse me, I'm wasn't explicit enough. It wasn't a question - it is a completion of the possible correct answers ...
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1493 :
ok
If you like our products and services, please help us by posting your review here.
-
- Posts: 4
- Joined: Sat May 25, 2019 10:21 am
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1493 :
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?
Make the bar method in Bar interface default like this - default void bar() { }
Shouldn't this be the correct answer?
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1493 :
What happened when you tried it out?
If you like our products and services, please help us by posting your review here.
-
- Posts: 4
- Joined: Sat May 25, 2019 10:21 am
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1493 :
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{
}
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{
}
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1493 :
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.
-
- Posts: 4
- Joined: Sat May 25, 2019 10:21 am
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1493 :
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!
My bad! Thanks for the reply!
Who is online
Users browsing this forum: No registered users and 112 guests