Facebook

adsense

Saturday 2 May 2015

QUESTION 12

What will happen when you attempt to compile and run the following code snippet?

String str = "Java";
    StringBuffer buffer = new StringBuffer(str);
    
    if(str.equals(buffer))
    {
        System.out.println("Both are equal");
    }
    else
    {
        System.out.println("Both are not equal");
    }
-----------------------------------------------------------------------------------
A. It will print - Both are not equal
B. It will print - Both are equal
C. Compile time error as you can not use equals for objects of different classes
D. Runtime error as you can not use equals for objects of different classes
E. None of these

<PREVIOUS || Main Page || NEXT >
GIVE YOUR ANSWER IN THE COMMENT BELOW

No comments:

Post a Comment