JAVA
Answer: Triangle t1 =new Triangle();
In Java, we have to use 'new' operator to create an object.
new Triangle(); creates an object of type Triangle and returns a reference of newly created Triangle object.
We should use a reference variable of type Triangle to store the newly created object reference.
We can declare a reference variable of type Triangle as follows:
Triangle t1;
We can now combine both the declaration of reference variable and Triangle object creation as follows:
Triangle t1 = new Triangle();
Please don't forget to give a Thumbs Up.
Get Answers For Free
Most questions answered within 1 hours.