Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Quiz Question : What is used to let a class know about a data type you want to use?

Wouldn't it be good to at least show the correct ans after one selects the wrong choice taking a quiz :(

Ritu, sorry, but I don't understand your question? I'll make a few guesses, but set me straight if I miss the target. Also, it's a good idea to ask the question using the Ask button, because that will put a link here that people answering your question can use to navigate to the challenge you're talking about. Without the name of the course, or a link to the challenge, all I know is that it is related to java.

You usually use data types when you create variables in classes:

int x = 0;
String s = "Hello, World!"
Date d = new Date();

Here the data types are int, String and Date.

You use data types when you give a method a non-void return type, and when you add formal parameters for your methods:

public double getArea(double width, double height) {
    return width * height;
}

Here the data types are double, double and double.

You use data types in programs when you are creating objects:

Scanner stdin = new Scanner(System.in);
Random r = new Random();
String s = new String("Hello, World!");
List<String> colors = new ArrayList<String>();

Here the data types are Scanner, Random, String and ArrayList<>, and the object stdin, r, s and colors.

If this totally misses the point let me know what the challenge question was.

An import statement

2 Answers

Hi jcorum , thanks that you took time to reply and yea I should've asked the question the way you said. It doesn't make sense without the things on the basis of which this question was asked, sorry :P I guess It came after I did some code on refactoring while creating individual java classes each to handle a particular task (single responsibility principle, I guess that's what they call it) for an android app and I was asked this question in the step that followed. Its based on some other context, I suppose. But hey even if it was a miss I really appreciate it :)

import statement