FAQs
Search
Recent Topics
Flagged Topics
Hot Topics
Best Topics
Register / Login
Win a copy of
Zero to AI - A non-technical, hype-free guide to prospering in the AI era
this week in the
Artificial Intelligence and Machine Learning
forum!
Yash Sharma
Ranch Hand
61
35
Threads
0
Cows
since Jan (61/100)
Number Threads Started (35 (61/10)
Number Threads Started (35/10)
Number Likes Received (0/3)
Number Likes Granted (0/3)
Set bumper stickers in profile (0/1)
Set signature in profile
Set a watch on a thread
Save thread as a bookmark
Create a post with an image (0/1)
Recent posts by Yash Sharma
Confused about OOP fundamentals!!
Abhinav,
I guess you didn't read the question or try to dry-run the program
There are two methods m and n, out of which m is surely overridden in the subclass. My question are two fold:
1) Why does the main method when run, prints "m from B, n from A" instead of "m from B, n from B"?
2) Why does the Javablackbelt answer says that method "n" is overloaded?
Regards,
Yash
P.S. If moderator deem it correct they may move the question to Beginners forum.
show more
11 years ago
Java in General
Confused about OOP fundamentals!!
I must have forgotten all my OOP fundamental. I had this question at Javablackbelt.com and am not sure why the answer should be m from B, n from A. The answer says that method n is overloaded in subclass but I though overloading only works in the same class. Can I request you to please explain the behaviour?
class A { void m(A a) { System.out.println("m from A"); } void n(A a) { System.out.println("n from A"); } } class B extends A { void m(A a) { System.out.println("m from B"); } void n(B b) { System.out.println("n from B"); } public static void main(String[] argv) { A a = new B(); B b = new B(); a.m(b); a.n(b); } }
show more
11 years ago
Java in General
For SCBCD5.0 (on EJB3.0) is experience on JDK1.5 needed?
Thanks a lot everyone. So for SCBCD its actually JDK1.5 + SCBCD for me
Tough job.
A related question:
Does preparing for SCBCD help me in clearing SCEA Part-1 as well?
show more
11 years ago
EJB Certification (OCEEJBD)
For SCBCD5.0 (on EJB3.0) is experience on JDK1.5 needed?
Hi,
I am planning to prepare for SCBCD5.0 (on EJB3.0).
1. Would I need to write code in JDK 1.5 syntax to pass it? I have been working on Jdk1.4 so far.
2. I clared SCJP 1.2 5 years ago, do I need to upgrade SCJP first? Am I eligible to write SCBCD5.0?
3. Also I hear that my HF EJB book has now gone to waste? If I were to buy only one book for SCBCD5.0 which one should it be?
Thanks for your advise.
Regards,
show more
11 years ago
EJB Certification (OCEEJBD)
Ant: Recursively build webapps
Hi,
I want to have a build file at the root for all my webapps that would recursively build all the webapps, albeit there would be no build files for individual webapps.
<target name="build-webapps" description="compile and create wars for individual webapps recursively"> <fileset dir="./components/webapps" includes="myfilter_*"> <build-macro </fileset> </target>
Here
build-macro
is a macrodef that would take care of building each webapp.
What I am not able to comprehend is how do I pass the name of the webapp folder to the macro. I don't want to hard code names as I want it to be generic to be able to handle any number of webapps in future without any changes in the build file. Note that individual webapp folders don't have a build file (or I could have used the subant task instead).
Thanks.
show more
12 years ago
Other Build Tools
Please suggest appropriate design pattern
As I mentioned, the intention is:
1) Ability to add new utilities with minimal code changes
2) Easier code maintenance
3) Should go with Portlets
show more
12 years ago
OO, Patterns, UML and Refactoring
Please suggest appropriate design pattern
Hi,
I have a Portlet application where I need to collate some utility JSPs that our team had written at various times. These utilities are standalone JSPs, for example one of them lists all running threads in the JVM, another reads the Manifest of a given JAR and so on. With a view that new utilities could be added and the code from JSPs have to be moved to a Portlet, please suggest appropriate Design pattern that could be applied here.
Thanks,
Yash
show more
12 years ago
OO, Patterns, UML and Refactoring
A protected static question
//Parent class package com.test.dir1; public class Parent { protected static void printHello() { System.out.println("Hello World!"); } } //Child class package com.test.dir2; import com.test.dir1.Parent; public class Child extends Parent { public static void printNewHello() { printHello(); } } //The main Class package com.test.dir3; import com.test.dir2.Child; public class Test{ public static void main(String args[]){ Child.printNewHello(); } }
Thanks for your replies. I am surely not mentioning Singleton class or a protected constructor here, not even a protected variable but a "protected static method" as mentioned above. Is the purpose to make it binding that before calling the method one must provide some implementation in a subclass? I would appreciate if somebody could tell me where in "real world" you would go for such a technique.
I was recently using an API and encountered the problem when trying to use the method threw an error saying that the method is protected and I had to do something like the code above.
show more
14 years ago
Java in General
A protected static question
What would be the design reason to make any method "protected static"? I am confused.
show more
14 years ago
Java in General
How is CSC Indore?
Has anybody had experience with CSC, especially howz their Indore unit. How is Java work there? How is the work culture compared to say Patni, Kanbay etc. Any inputs from people who have worked there would be appreciated.
show more
15 years ago
Jobs Discussion
Hierarchy problem
I have a doubt. I have a task on hand where I have to port an application from one framework to another. Image we have a super class "GrandDad". Now, one of class hierarchies (in Framework 1) is:
Grandson extends Son extends Father extends GrandDad
Another hierarchy (in Framework 2) is:
Uncle extends GrandDad
In porting from FW2 to FW1, if I make change such that: Uncle extends Grandson (I do this so that I get all the new functionalities that were added to GrandDad by the Father, Son and Grandson).
What impact will it have on my design? Or am I doing something evil?
show more
15 years ago
Java in General
Create GUI from and saving stuff to XML
I am confused about the approach I should take on this.
I am using XML as my data-model. A web-based GUI would prepare the GUI from this XML. Let's say this is a Book XML where using the GUI user could (1) select his preferred chapter and (2) Save this choice. To generate the GUI and saving user's preference I plan to use the same XML (say master.xml).
The XML:
<?xml version="1.0" encoding="UTF-8"?> <book title = "Test Book"> <chapter title = "Chap1" /> <chapter title = "Chap2" /> </book>
The GUI can certainly be made from this, a drop down containing all the chapter titles and a button to save the preference. When the user saves it, the XML would be saved (as say user_xyz.xml) and looks like:
<?xml version="1.0" encoding="UTF-8"?> <book title = "Test Book"> <chapter title = "Chap1" preferred="yes"/> <chapter title = "Chap2" /> </book>
So far so good
Imagine now that the author adds few more chapters so the XML now becomes:
<?xml version="1.0" encoding="UTF-8"?> <book title = "Test Book"> <chapter title = "Chap1" /> <chapter title = "Chap2" /> <chapter title = "Chap3" /> <chapter title = "Chap4" /> </book>
I see no problem in saving a new preference the GUI dropdown will now display four chapters instead of two. However, what if the user XYZ decides to alter his preference, if my GUI is created using "user_xyz.xml" the GUI is not aware of the additional two chapters now available. If it is created using "master.xml" it has no knowledge of the user's previous preference.
I hope I made myself clear. Should then my approach to creating the GUI be parsing both master and user's XML and then create it, could be taxing if XML is complex and bulky. Or should I update the user's xml every time master changes, again how will I update it. Or is there any other suitable approach?
Thanks for your time.
show more
15 years ago
XML and Related Technologies
Freemarker XML problem
I have a scenario where my data-model is XML and I have to generate a JSP from this based on a template. This XML is not as simple as the Book.xml discussed in the examples of Freemarker.
Now I am stuck with how to get the attributes, Say I have the XML:
<book>
<title>Test Book</title>
<chapter title="Chapter 1" pages="2">
<para title="First Para" weight="1" align="Left">p1.1</para>
<para title="Second Para" weight="3">p1.2</para>
<para title="Third Para" weight="2" >p1.3</para>
</chapter>
</book>
In this case the Nodes have "attributes" some are not mandatory (may be there or may not be), what I mean to say is that the number of attributes for an element is not fixed.
When I display the ${.node?node_type} I always see the type as "element", the attributes are not traversed. I know I must be doing something stupid (I do not have any experience with XSLT etc). I was not able to locate a solution at the docs.
Can anybody help me with this? A pointer to some existing resource would also help a lot. Thanks for your time.
Regards,
[ February 01, 2005: Message edited by: Yash Sharma ]
show more
15 years ago
Other Application Frameworks
Calling ANT task from Java program
Sorry if this sounds naive
I want to use the ?
Freemarker ANT task
to generate an HTML representation for my XML based on a template. However I want to do this using my program on the fly, which means that I must be able to call the ANT task from inside my Java program.
Can we call an ANT task from a Java Program or JSP?
show more
15 years ago
Other Build Tools
Generate JSP based on template
I don't know whether this was too stupid a question.
I also wish to ask whether "Velocity" fits the bill here ?
show more
15 years ago
Other Application Frameworks