> For the complete documentation index, see [llms.txt](https://mun.gitbook.io/ad/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mun.gitbook.io/ad/oop/sample-questions.md).

# Sample Questions

## Output Tracing

```java
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.
