Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!

Alangudi Balaji Navaneethan

Ranch Hand
+ Follow
since Apr 28, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Alangudi Balaji Navaneethan

Sagar,

Naandri means saying Thankyou in Tamil. I am glad to know that Chad Fowler knew great ancient yet living language "Tamil".

I havent read the book of chad yet. But the title inspired me and read the reviews of the book in amazon.com. They increased my curiosity to read the book. Hope I can get it soon.

Thank you Chad for such good book.
11 years ago
I studied in Head First Java that,

We need to provide a constructor with arguments to instantiate a class with initial values. If we do not provide any constructor one will be arranged by jvm.

I also read in a book that, if we give constructors with arguments then we must also give constructors without arguments also...

But when I tried the following program I am puzzled with the results what is the problem



I expected a compile time error. But it compiled and gave 100 as result.
Hello Raghu,

Can you share with me your success story... What was your road map to from just a beginer to a certified professional...
Yes,

In first four method calls, you create a reference to superclass and pass base,sub and super objects. But actually you are calling method of superclass. In the last method call you create a reference to base class and call the method of that object...

You did not override print methods... you did not call methods of any derived objects that are reference by superclass variable...

hope you can understand now.
The idea behind encapsulation is to support data hiding or protecting data from malicious access.

At the first stage of your program you think that your instance variable can be accessed by anyother class's objects directly. You know that who are going to use your code and how will they use.

Suppose in future you may change your mind that your users must be given some way to access your instance variables. That is, you want to have the control of how to access the variable. You want others to access the variable by providing them a way to access it. No other way other than this. This is an idea about encapsulation.

For better understanding study any Object Oriented Concepts Book.
Yes,


I also tried with int and an Integer object. The expression is switch accepts it. But the case statement complains that the expression must be constant expression. I have tried as,

Integer in = new Integer(12);
switch(in)
{
case in: system.out.println(in.intValue());
case in.intValue(): System.out.println(in.intValue());
}
Both statements failed...
thanks to Krow and Manoj,

I also have tought to start with head first servlet and jsp. I have a little but sufficient knowledge in core java to start with. But with HTTP and other web related stuff, how depth should I have to learn.. Is it mandatory to learn TCP/IP and HTTP in detail?
14 years ago
Yes,

The JVM will call the constructor of the super class in order to do some household works that the objects of the derived classes need to do.

abstract class Base
{
protected i;
protected void Base()
{
i=10;
}
}

class Derive extends Base
{
protected int j;
public void Derive()
{
super();
j = i * 20;
}

public static void main(String[] arg)
{
Derive der = new Derive();
}
}
Hi Kethy,

If so what Have I said is correct?
Hi,

I am new to servlet and jsp. Where should one start after having an idea in Java programming. Anybody here to show me the road map to take?
14 years ago
Hi,

You can consider the constructor as a process to create an object. and object as the result of constructore. If the constructor fails there will be no object. an object creates itself... through constructor.

The hen creates the egg of itself and come out the egg... do you understand....
Hi,

thanks for your valuable comments. I identified what mistake I have comitted. I corrected them and my code worked well. Thanks a lot especially to Krishnan...
Hi,

What they have written is correct. It should be understood that inside the package where the subclass is, only the subclass and the subclasses of it are able to access the protected member which has been declared in any outer subclass as protected...
hi,

if you have clarified your doubt. then you can close the topic. So that others can help some body else.
Hello all,

I tried the code resembles the one given in Head First Java.
The program tries to sort a name list file contains first and last names. The comparision is based on first name.

The compareTo method works fine with Strings. But to compare the custom class we need to implement Comparable interface and override compareTo method. Am I right?