The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+17 votes
1.2k views

Which of the following statements is FALSE?

  1. In statically typed languages, each variable in a program has a fixed type
  2. In un-typed languages, values do not have any types
  3. In dynamically typed languages, variables have no types
  4. In all statically typed languages, each variable in a program is associated with values of only a single type during the execution of the program
asked in Programming by Veteran (59.4k points) | 1.2k views

2 Answers

+14 votes
Best answer

Answer is (C). In dynamically typed languages variables do have type- just that it is inferred during runtime.

answered by Veteran (342k points)
edited by
0

comment on the main answer saying that "Almost. "This in practice means that you as the programmer must specify what type each variable is" is not true for statically typed languages with type inference, like Haskell, OCaml, "Perl 6", etc" @ http://stackoverflow.com/questions/1517582/what-is-the-difference-between-statically-typed-and-dynamically-typed-languages  
..... does it make the option (A) false ??
 

0
That is not contradicting option A. "Having a type" and "inferring a type" are both different.
+2
even b should be incorrect?..as values have types variables do not ,in untyped languages isnt it?
0
In (D) option

In a program if we take a variable in two different type in two different function call , which kind of error it will generate?
+3

@srestha

Do you mean 

int a = 10;
{ 
    float a = 1.0;
}

This won't generate any error as 'a' inside and outside the block are different variables (just that name is same). 

0
Could u pls explain what is statically typed , dynamically typed , no typed means ??
+12

A language is statically typed if the type of a variable is known at compile time. For some languages this means that you as the programmer must specify what type each variable is (e.g.: Java, C, C++); other languages offer some form of type inference, the capability of the type system to deduce the type of a variable (e.g.: OCaml, Haskell, Scala)

The main advantage here is that all kinds of checking can be done by the compiler, and therefore a lot of trivial bugs are caught at a very early stage.

A language is dynamically typed if the type is associated with run-time values, and not named variables/fields/etc. This means that you as a programmer can write a little quicker because you do not have to specify types every time (unless using a statically-typed language with type inference). Example: Perl, Ruby, Python

0
nice... :)
–1 vote
Answer is a.
answered by Active (3.3k points)
0
what is type inferencing?
Answer:

Related questions



Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

35,499 questions
42,768 answers
121,499 comments
42,151 users