What will be the output of the following Java code?
    class output 
    {
        public static void main(String args[])
        {
             String chars[] = {“a”, “b”, “c”, “a”, “c”};
             for (int i = 0; i < chars.length; ++i)
                 for (int j = i + 1; j < chars.length; ++j)
                     if(chars[i].compareTo(chars[j]) == 0)
                         System.out.print(chars[j]); 
        }
   }
a)	  ab
b)	  bc
c) ca
d) ac
Answer: d
	Explanation: compareTo() function returns zero when both the strings are equal, it returns a value less than zero if the invoking string is less than the other string being compared and value greater than zero when invoking string is greater than the string compared to.
output:
ac
    
						
						
												
							Related Posts
- Empdt1(empcode, name, street, city, state, pincode).
 For any pincode, there is only one city and state. Also, for given street, city and state, there is just one pincode. In normalization terms, empdt1 is a relation in
- Which forms are based on the concept of functional dependency:
- Which forms has a relation that possesses data about an individual entity:
- Which forms simplifies and ensures that there are minimal data aggregates and repetitive groups:
- Which is a bottom-up approach to database design that design by examining the relationship between attributes:
- Functional Dependencies are the types of constraints that are based on______
- Which-one ofthe following statements about normal forms is FALSE?
Join The Discussion