Sample Questions
Output Tracing
class SimpleCompare{
public static void main(String args[]) {
String s = new String("hello");
String ss = "hello";
String sp= "hello";
System.out.println(s.compareTo(ss));
System.out.println(s==ss);
System.out.println(s==sp);
System.out.println(ss==sp);
}
}
Write Java Programs for the following questions:
Write down a method to find how many times an object has been instantiated in Java.
Write C++Programs for the following questions:
Write down a program in c++ using copy constructor to initialize its member variable from another object.
Last updated