Can we access a private variable in another class in typescript
<pre><code>class Animal {
    private name:string;
    public Firstname:string;
    constructor(theName: string)
    {
        this.name = theName;
        this.Firstname=theName;
    }
}

class Tiger {
    function sample(){
        Animal animalName=new Animal('Tiger');
        document.body.innerHTML = animalName.name;
    }
    sample();
}
</code></pre>
<p>Hi am new to this TypeScript here in animal class I've created a private variable name I used that in class constructor. Now in class <code>Tiger</code> I created the instance for <code>Animal</code> class and able to access that private variable.</p>
<p>My question is in Java if we do we will get error. But in TypeScript (because TypeScript supports OOPS) we are not getting any error moreover it is giving the value how is it possible?</p>