Homework Answers

Answer #1

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.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Java programming. Fill the empty boxes with the Answer. 1) The Java compiler javac translates Java...
Java programming. Fill the empty boxes with the Answer. 1) The Java compiler javac translates Java source code into [Answer]. 2) In Java a class object can inherit the properties of a superclass by using the [Answer] keyword. 3) A(n) [Answer] method consists of the same method name but different number or types of parameters 4) In a class definition, the special method that is called to create an instance of that class is known as a/an [Answer] 5) The...
a) Write a java statement to import the java utilities. b) Create a Scanner object to...
a) Write a java statement to import the java utilities. b) Create a Scanner object to read input. c) int Age; Write a java statement to read the Age input value.     Write a java statement to read the Age input value.
1. a. Write the Java code to fill a Java array of ints of size 100...
1. a. Write the Java code to fill a Java array of ints of size 100 with the value -1. b. Write the Java code to create an ArrayList of Strings, and add the Strings "Just", "Do", "It!" to it.
<Java Programming> as mentioned in the text, a java identifier consists of one or more characters....
<Java Programming> as mentioned in the text, a java identifier consists of one or more characters. The first character must be an uppercase or lowercase letter of the alphabet, an underscore _, or a dollar sign $. Each remaining character must be an upper case or lowercase letter of the alphabet. a digit 0-9, an underscore, or a dollar sigh. Write a Java program that reads in a line of characters and prints out whether the line of characters is...
Develop an Algorithm and java program using Design Recipe: 1) Develop a java program to the...
Develop an Algorithm and java program using Design Recipe: 1) Develop a java program to the content of one file to another. Hint 1: read() Hint 2: write() 2) Develop a java program to List all files in a given directory. Hint: list()
46. rding Java thread scheduling, which of the following statements are true? a. The Java API...
46. rding Java thread scheduling, which of the following statements are true? a. The Java API provides no direct support for scheduling threads at a fixed rate. b. Java threads may be scheduled differently on different systems. c. The JVM has a very strictly-defined thread scheduling policy. d. Invoking the yield() method ensures a thread yields control of the CPU.
Java discussion: There are several Integrated Development Environment(s) (IDEs) for Java. We have been using Eclipse...
Java discussion: There are several Integrated Development Environment(s) (IDEs) for Java. We have been using Eclipse as the IDE for this class. There are a couple more popular Java IDEs that some of you may have used or heard about in the past. These include NetBeans and  IntelliJ IDEA.   For this discussion, you are to compare and contrast the similarities and differences between Eclipse and one other Java IDE. You should also discuss the advantages and disadvantages of each.   (written in...
Write Java program Lab51.java which takes in a string from the user, converts it to an...
Write Java program Lab51.java which takes in a string from the user, converts it to an array of characters (char[] word) and calls the method: public static int countVowels(char[]) which returns the number of vowels in word. (You have to write countVowels(char[]) ).
Java programming 1) Which among the choices is the following Java expression equivalent to? !((b !=...
Java programming 1) Which among the choices is the following Java expression equivalent to? !((b != 0) || (c <= 5)) Select one: a)       (b != 0) && (c <= 5) b)       (b == 0) && (c > 5) c)       !((b <> 0) && (c <= 5)) d)       (! (b = 0)) && (! (c > 5)) e)       (b == 0) && (c <= 5) 2) The scope of a variable is an important feature in Java, the following variable...
JAVA QUESTION I want to know how to combine different Shape objects in Java into one....
JAVA QUESTION I want to know how to combine different Shape objects in Java into one. For example, if I wanted to make a class called CoffeeCup, and it was supposed to be a to go coffee cup, how would I combine a Rectangle, and two Ellipses (on the top and bottom) and then use that as one object in a different class? Thank you in advance!