Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
String[] mytab will create an array of Strings named mytab...
And second question, I am not able to understand.. -
1. Declares a string array with the name mytab.
2. Types are for PC's so they know how much memory they should reserve.
I havent worked with typed languages for 5 years now sadly enough. But these are the answers I would give. -
ZooS1ne567y1. This will only declare a member of type String array, it will not create or initialize it (since no constructor or initializer was given, like size of array or array members)
2. I am not sure what do you mean by this question. If you are refering to Java, tPes declare what the member is. Is it int, Sting, List and so on. Each type in Java (except the primitive tyles) is derived from an Object type. In very simple terms it tells the virtual machine how to handle the members data -
@Codex404 What this guy said, and more -
Types tell the pc to reserve a certain amount of memory. E.g integers (int) take 4 bytes (i think). So when you declare something of type integer, 4 bytes are reserved for that integer variable. -
CptFox16197y1. Creates a recipient for an array of strings. If I remember right, initialization has to be explicit, so mytab should be a null reference.
2. They define how data is stored and handled. They serve both as a mechanism for the computer to know how much memory to allot, as well as an aid to the developer to ensure data is handled predictably (let's face it, properly is not always the word for how we handle our data).
What would your answers be ? -
shdw9507yAgree with comments above. Also types are for data integrity.
Example: One would like to know that x is a double and not a string, if you were to calculate the average result of some scores.
In JavaScript you can do: var x = 1 + “1”; which would return “11”. In Java you would do: int x = 1. If you were to add “1” (a string) to x, the compiler would shout at you. This saves a lot of debugging and messy code you could end up with. -
@Codex404 @ZooS1ne My answers are :
1. It declares a variable of type "array of strings" containing null because no memory has been allocated yet
2. A type is used to define the amount of memory needed to store a variable.
But the "correct" answers are (according to the test) :
1. It declares a variable of type array and builds strings initialized to "".
2. Types define the possible values of a variable -
ZooS1ne567y@GarreauArthur I would say it is not a completely wrong answer...
It just depends on how technical you want to get -
mrblarg877yTypes are a lot more than memory layout, they're an abstract concept. All data is typed, whether or not your language makes you state that type. Types are defined by the set of operations you can perform on them. In Java, types are usually expressed as classes or interfaces. So I guess the purpose of a type is to restrict nonsense operations like uppercasing a float.
OMFG, so I had a quick exam about Java but disagree with 2 answers. So I just want to know what you would have answered :
What does "String[] mytab" do ?
What are types for ?
question