Solved

Java question regarding abstract method implementation

Posted on 2011-03-20
6
498 Views
Last Modified: 2012-06-21
Hi experts,

I was referring some open source java code of android. In one of the classes, I saw a method call to another class. The method called was an abstract method inside an abstract class. As is expected, the abstract method do not have any implementation. But, to my wonder, this abstract method returns a List. I do not know, without having any implementation(and return statement) for a method, how this method returns a List?

Please refer the code attached.

Any help in this regard would be appreciated.

Best Regards,
Sreejith
// Calling Method

final List<ResolveInfo> apps = manager.queryIntentActivities(mainIntent, 0);

//Called Method inside another abstract class

public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
            int flags);

Open in new window

0
Comment
Question by:Sreejith22
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
ID: 35178480
The implementation would be in a subclass of the abstract class
0
 
LVL 92

Assisted Solution

by:objects
objects earned 250 total points
ID: 35178482
though you shouldn't generally need to see the implementation

http://download.oracle.com/javase/tutorial/java/IandI/abstract.html
0
 

Author Comment

by:Sreejith22
ID: 35179350
Hi Objects,

Thanks for your reply. I found out the sub class  of this abstract class which has this method. When I provided a log inside this method, I found out that, this method is being called 5 times, while I was just expecting a single call.

Is there any method by which, I can identify the class(or method), from which this method is called, by providing a log inside called method?
0
Get Actionable Data from Your Monitoring Solution

Your communication platform is only as good as the relevance of the information you send. Ensure your alerts get to the right people every time with actionable responses. Create escalation rules that ensure everyone follows the process and nothing is left to chance.

 
LVL 92

Assisted Solution

by:objects
objects earned 250 total points
ID: 35179407
0
 
LVL 4

Expert Comment

by:msk_apk
ID: 35180092
when you call ,

final List<ResolveInfo> apps = manager.queryIntentActivities(mainIntent, 0);

manager must be pointing to the object in which the method queryIntentActivities is implemented.
0
 

Author Closing Comment

by:Sreejith22
ID: 35204462
Thanks objects!
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
If you use the Google Now Launcher, as an aftermarket add on, have a Samsung Note 5 and are worried about power consumption be wary of using the ultra power saving mode.  Here is what happened to me when I made the mistake of trying this out...
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question