Wednesday, August 31, 2005

AJAX in Action

Although I know that this isn't *strictly* Java programming, but I felt I needed to share this article on Ajax - 'AJAX in Action'.

Once you have read the article above, which is concise and to the point, you might want to check out this article from Sun, that answered the next question that popped into my mind - great! Now, how about an example that links it with J2EE. Read it here.

Tip: For the newcomers, here's a really basic article on the topic.
Technorati Tags:
Blogs linking to this article

Package for a Java Bean

This blog entry is for answering the question posted by Medha in the blog entry "Java Questions".

Question: Why do we need to declare a specific package name for all the beans we intend to use in JSP pages?
Answer: Even though the bean specification doesn't require it, I recommend that you always declare a specific package name for all beans you intend to use in JSP pages, via the Java package statement.

If you don't, you have to use the JSP import directive to import the bean class (with the page directive) in every JSP page that uses it. The page implementation class may use a vendor-dependent package name; since Java assumes that a class name without a package qualifier refers to a class in the same package as the class that uses it (or to a package declared by an import statement), the compiler looks for the bean class in the wrong package unless you explicitly import it.

I hope this clears your doubt, Medha.
Technorati Tags:
Blogs linking to this article

Tuesday, August 30, 2005

Java Questions

This post is a Work-In-Progress and I am going to post here, commonly asked Java Questions and their Answers. I am requesting all members to atleast post their questions, as comments.

2nd Sept. 2005
Questions by Vijay Jadhav
(a) Write Java code to remove the trailing spaces in a string, without using the trim() method.
Answer provided by Pushpendra Bharambe
public class TrimString
{
public static void main(String[] args)
{
String str = "Hello World ";

System.out.println("Length of str = " + str.length());
while (str.endsWith(" "))
{
int k = str.lastIndexOf(" ");
str=str.substring(0, k);
}
System.out.println("Length of new str = " + str.length());
}
}
What if we wanted to remove all spaces from a Java String?
Answer provided by Vishal Dedaniya
public class RemAllSpaces
{
public static void main(String[] args)
{
String s=" ab bc cvnf v ", s1;
int x;
char[] c;
c = s.toCharArray();
for(int i = 0; i < c.length; i++)
{
if(c[i] != ' ')
{
x=0;
System.out.print(c[i]);
}
}
}
}
(b) Write Java code to insert a character at an index, in an array of characters.
Answer awaited.

31st Aug. 2005
Question by Medha Shewale
(a) Why do we need to declare a specific package name for all the beans we intend to use in JSP pages?
Answer to Medha's question above.

Questions by Rahul Kulkarni
(a) Why should we override the equals() method of the Object class?
(b) If we override the doGet() and doPost() method of a Servlet class, which one is called first, by the container?
Answers to Rahul's questions (a) and (b) above.

Update: GeekInterview is an Open Database where you can share interview questions, comment/answer any questions without any registration just by providing name and optional email address.
Technorati Tags:
Blogs linking to this article

Interfaces Vs Abstract Classes In Java

Interfaces Vs Abstract Classes In Java - Have you ever wondered why you should use interfaces instead of abstract classes, or vice versa? More specifically, when dealing with generalization, have you struggled with using one or the other? Anthony Meyer sheds some light on what can be a very confusing issue.

Anthony Meyer is a technical director and a Java developer at Flashline.com. His experience includes the design, development and implementation of large-scale, Java-based, Internet applications in the corporate Web development environment. He has also created and implemented corporate-focused reuse strategies in the financial industry.
Technorati Tags:
Blogs linking to this article

Mustang and Dolphin

Did you know that Java 2 Platform, Standard Edition (J2SE 6.0), code name Mustang, is due in the first half of 2006 and that Dolphin, the Java SE 7 release is scheduled to follow Mustang in late 2007?
Technorati Tags:
Blogs linking to this article

Monday, August 29, 2005

Java Language Keywords

It's surprising that sometimes even experienced Java programmers are not sure whether a particular word is a Java Language Keyword or not. The Java Tutorial has an updated list, that all can refer to.
Technorati Tags:
Blogs linking to this article

First Post

Some of you indicated that we start a PuneJava blog and so here it is. This blog can only evolve if you all contribute your time towards the same. Our member, Nikhil Palshikar pointed out that this blog could "collect and post articles that explained the fundamental aspects of Java and encouraged Java developers to read and understand these aspects. This in turn would take them far in their professional life". Kindly post your comments to this first post and make your suggestions. Angelina Peters, Sanjay Hande, Shailesh Barde and Abhijit were some of the first who were all for, for a PuneJava blog.
Update (30/8): Dileep Dharma, Nikhil Palshikar and Mayuresh Kadu have agreed to contribute articles on a regular basis. If anyone else is interested in contributing articles, Java related news items etc., please send me an email.
Technorati Tags:
Blogs linking to this article