Jump to content

albertlee

Senior Members
  • Posts

    1259
  • Joined

  • Last visited

Posts posted by albertlee

  1. thanks for the replies

     

    to cap: I have disabled all my firewalls, but problems still appear.

     

    to insane: I always use the administrator privilege to open up my programs, by right clicking their icons and select the open with administrator privilege option.

     

    I can definitely access the Internet on IE. BUT, I can't even do a "ping" command on the command prompt in Vista. This is indeed very strange, since if there is connection, "ping" command should always work. That is, I can't ping a host like google or yahoo for example, but the strange thing is I can ping and get response from my ISP's DNS server.

     

    Any help or explanation to my problem?

     

    thanks

  2. say, on a graphic of cubic function, there is a root at 2, a y point on 8 when x is 1, and another on 8 also when x is -1, and when x is 0, y = 8.

     

    1) if I solve this by:

     

    (x-2)(ax^2+bx+c).... I get an answer because I can solve a, b, c by 3 different simul equations.

     

    but

     

    2) if I solve this by:

     

    (x-2)(ax+b)(x+c), I get more answers because when I try to solve c, I get a quadratic equation for it, which means c can have 2 values...... but this cannot be possible, since c can only be one value as a root.

     

    plz help

  3. btw, why I cant compile this code?

    public class b{
    
    static class a{}
    static class b1 extends a{}
    static class c extends b{}
    
    
    static <A extends b.a> void adds(LinkedList<A> l, A b1){l.[b]add(b1)[/b];}
    
    static public void main(String[] sfg){
    
    
    LinkedList<c> l = new LinkedList<c>();
    
    adds(l, new c()); }
    
    
    }
    

     

    and the problem originates from the bold part of the code above....during compile time.

     

    Please help

     

    thx

  4. Heh, sorry, that was a typo and should have been "1". The rest of it doesn't change (ie I simply typed 2 but meant to type 1 in that instance). Hope it makes more sense now. You can see this from the fact it says "but there is nothing at the position because that was the position taken by k1" which would mean that it would have to be "2".

     

    Ok, so...

     

    When will the hashcode of k2 really be changed to "1" in the HashSet?

  5. Ok... sorry, forget about my last post.

     

    Weird, it did work like the day before yesterday, now I get a compile time error, as you said. :confused:

     

     

    Any way,

     

    protected class A{
    
    int a;
    
    static int b;
    
    void meth1(){};
    
    static void meth2(){};
    
    }
    

     

    is the above code equivalent to the below one in terms of accessibility?

     

    public class A{
    
    protected int a;
    
    protected static int b;
    
    protected void meth1(){};
    
    protected static void meth2(){};
    
    protected A(){};
    
    }
    

     

    btw, why cant you use "private" modifier to a class?

     

    plz help

     

    thx

  6. oh sorry...

     

    I think I need some sleep...:)

     

    I thought they were both "Square", but I actually overlooked. One of them is "Shape", not "Square"....

     

    Any way, please help answering my feedback questions on question 5....

     

    thx

  7. This is the funky bit, as k2.i has now changed to 1 (it was originally 2), k2.hashCode() will return 2, and HashSet will use that to look for it, but there is nothing at the position because that was the position taken by k1, k2 was originally placed into whatever place is specified by "2" not "1". Therefore as it can't find k2, it simply fails. k2 has not been removed, it is still at "2", it hasn't moved, it is simply that the hashCode() has changed and so HashSet tries to look for it in a different place.

     

    why???

     

    this is the implementation of the hashCode method in my posted question:

    public int hashCode(){return i;}

     

    clearly, the method should return "1" not "2".....why would you see it's 2???

     

    can you please explain more clearly why?

     

    please help

     

    thx

  8. thanks for the responses, Aeternus...

     

    However, I still dont comprehend the 2nd question...

     

    for example:

     

    package a;
    
    public class fc{
    
    public a aa = new a();
    
    private class a{public int d = 5;}
    
    
    }
    

    and

    import a.fc;
    
    
    public class Test{
    
    public static void main(String[] sref){
    
    
    fc c = new fc();
    
    System.out.println(c.aa.d);
    
    
    }
    
    }
    

     

    In the second code, note that it's in the super directory of directory "a", I can access the varriable d, which is in the private class, without getting any error.....

     

    So, again, why does the answer of question 2 is that it's unable to refernce varriable i (which is now d in this case) when the class is outside the package the referenced variable is in?

     

    please help

     

    thx

  9. Question 6:

     

    import java.util.*;
    
    public class Test {
    
     public static void append(List list) {list.add(new Object()); list.add("bbaa"); list.add("1122"); list.add(1234);}
    
    
     public static void main(String[] argv) {
    
    List<StringBuilder> intList = [b]new ArrayList<StringBuilder>()[/b];
    
    append(intList);  
    
    
           System.out.println(intList.get(0));
    System.out.println(intList.get(1));
    System.out.println(intList.get(2));
    System.out.println(intList.get(3));
    
    
    
    
     }
    }
    

     

    Why there is no runtime error at append(intList)? I know the parameter accepts it, but the instance actually only allows to add elements of StringBuilder type....

     

    please help

     

    thx

  10. Question 5:

     

    public String s(){
    
    [b]String s = "Fred";
    s += "47";
    s = s.subString(2,5);
    s = toUpperCase();[/b]
    
    return s.toString();
    }
    

     

    how many String objects are created when the method s is invoked?

     

    my answer is 4, but the correct one is 3...why?

    As you see in the bold section of the code block, each line will create a new String, since String is immutable...

     

    plz help

     

    thx

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.