Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #161 (permalink)  
Old 05-16-2008, 05:26 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 509
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
Im back!!!!

@ rjuyal, you have the correct guess,

@ eku, lacking....

actually it is compilable and runnable code....
There is a member here who asked about nested extending of abstract classes(i may be wrong of its term)... i doubt at first, bec i really don't use that kind of implementation, and i replied to him that experimental code.....

@ eranga,
all within the contructor test will first to execute before at the main method... you're right....

@Jesdisciple
you're correct too,
Quote:
But I think the compiler would complain that "Class B cannot be found" or something to that effect.
the compiler will not complain....

Generally, any class that was extend at the main class(handler) can be invoked its method within the main class by "this" referencing....
Any abstract classes that was extended from other abstract class which extended also in the main class(handler), can be invoked its method directly to main class(handler)...

next quiz please?!!
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #162 (permalink)  
Old 05-16-2008, 05:29 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,403
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
But I think you should have compiler warning. Because you are accessing non-public types here, through a public. Isn't it?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on July 13, 2008)
Bookmark Post in Technorati
Reply With Quote
  #163 (permalink)  
Old 05-16-2008, 05:37 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 509
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
no warnings at all....

because, if the said abstract classes were not specified as public or private, it will then set to the default(can access within the package)....

and obviously the abstract classes are together with the main class(test)

please correct me if i'm wrong,

you can test the code with -Xlint
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #164 (permalink)  
Old 05-16-2008, 05:49 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,403
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Ok, I'm talking about this.

Code:
public class test extends B
Class B is not a public class, so you are exporting a non-public class here in a public class. Best thing to do is, define the test class with default modifiers. It's a fixable warning, generally we called it is.

It's better check this myself too on an IDE now.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on July 13, 2008)
Bookmark Post in Technorati
Reply With Quote
  #165 (permalink)  
Old 05-16-2008, 05:57 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 509
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
What's the result?!!
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #166 (permalink)  
Old 05-16-2008, 06:23 AM
Eku Eku is offline
Senior Member
 
Join Date: May 2008
Location: Makati, Philippines
Posts: 174
Eku is on a distinguished road
@sukatoa. . . I was really confused on that question. ^_^ another lesson learned
__________________
Mind only knows what lies near the heart, it alone sees the depth of the soul.
Bookmark Post in Technorati
Reply With Quote
  #167 (permalink)  
Old 05-16-2008, 06:25 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,403
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Quote:
Originally Posted by sukatoa View Post
What's the result?!!

Nothing, there is a warning. But your code is still compiled and run perfectly. All about access modifiers level.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on July 13, 2008)
Bookmark Post in Technorati
Reply With Quote
  #168 (permalink)  
Old 05-16-2008, 06:28 AM
Member
 
Join Date: May 2008
Posts: 22
Jesdisciple is on a distinguished road
What's the result (output or compile/runtime error/exception) of this?
Code:
class B { String value; B(String value){ this.value = value; } public String toString(){ return value; } static void test(A<? extends Object> a){ a.set(new B("foo")); System.out.println(a.get()); } public static void main(String[] args){ A<B> a = new A<B>(); test(a); } } class A<T> { private T o; void set(T o){ this.o = o; } T get(){ return o; } }
Bookmark Post in Technorati
Reply With Quote
  #169 (permalink)  
Old 05-16-2008, 06:39 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,403
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
This is much simpler pal. Got the compile error.

It's all about set()
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on July 13, 2008)
Bookmark Post in Technorati
Reply With Quote
  #170 (permalink)  
Old 05-16-2008, 06:40 AM
Member
 
Join Date: May 2008
Posts: 22
Jesdisciple is on a distinguished road
Did you compile it, then?
Bookmark Post in Technorati
Reply With Quote
  #171 (permalink)  
Old 05-16-2008, 06:46 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,403
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Oh, I'm not compile it. It wont compile it, because set() on class A not extended, but in class B you tried it. So it wont compile.

Simply incompatible method signature found.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on July 13, 2008)
Bookmark Post in Technorati
Reply With Quote
  #172 (permalink)  
Old 05-16-2008, 09:10 AM
rjuyal's Avatar
Senior Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 160
rjuyal is on a distinguished road
1st thing first
Quote:
Class B should be declared as public to run this program
__________________
Newton said Gravitaion, Rakesh says Earth Sucks
Bookmark Post in Technorati
Reply With Quote
  #173 (permalink)  
Old 05-16-2008, 09:40 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,403
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
I think still you get the same warning.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on July 13, 2008)
Bookmark Post in Technorati
Reply With Quote
  #174 (permalink)  
Old 05-16-2008, 11:50 AM
rjuyal's Avatar
Senior Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 160
rjuyal is on a distinguished road
why i don't get the notification

anyways which kinda warning?
__________________
Newton said Gravitaion, Rakesh says Earth Sucks
Bookmark Post in Technorati
Reply With Quote
  #175 (permalink)  
Old 05-16-2008, 12:19 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,403
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Should be much similar to this.

Quote:

set(extends object) in class A<extends object> cannot be applied to class B
I guess it should be. Why is that your Eclipse doesn't give such notifications.

I'm not sure my NetBeans give it too.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on July 13, 2008)
Bookmark Post in Technorati
Reply With Quote
  #176 (permalink)  
Old 05-16-2008, 02:09 PM
rjuyal's Avatar
Senior Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 160
rjuyal is on a distinguished road
Quote:
Why is that your Eclipse doesn't give such notifications
My Eclipse will certainly give much more elaborated, correct, acceptable ( out of words, add from your side ) warning. but i have not compiled it though,as the rule says
__________________
Newton said Gravitaion, Rakesh says Earth Sucks
Bookmark Post in Technorati
Reply With Quote
  #177 (permalink)  
Old 05-17-2008, 05:59 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,403
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Yes pal that's true. Even me never touch the IDE. I thought after answering you test it ans says that. Sorry if I say some annoying thing there.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on July 13, 2008)
Bookmark Post in Technorati
Reply With Quote
  #178 (permalink)  
Old 05-25-2008, 08:31 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,403
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Seems all are silent here. I don't want to be like that. So here I'm,

Code:
public interface myInterface extends intOne, intTwo { private float temp = 12.234F; int addIntegers(int i, int j); }
My question is, the above code is valid or not. Please don't compile it before answering.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on July 13, 2008)
Bookmark Post in Technorati
Reply With Quote
  #179 (permalink)  
Old 05-25-2008, 08:55 AM
rjuyal's Avatar
Senior Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 160
rjuyal is on a distinguished road
i guess all variables in interface should be public staic final, so it should not compile.
__________________
Newton said Gravitaion, Rakesh says Earth Sucks
Bookmark Post in Technorati
Reply With Quote
  #180 (permalink)  
Old 05-25-2008, 09:21 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,403
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
[Yep, it's right. Because interface body only can contain constant declarations only. And if you want that set of modifiers can be omitted.

Next quiz?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on July 13, 2008)