in Programming
25 votes

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
in Programming

Subscribe to GO Classes for GATE CSE 2022

3 Answers

24 votes
Best answer

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

edited by


reshown by

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" @  
..... does it make the option (A) false ??

That is not contradicting option A. "Having a type" and "inferring a type" are both different.
even b should be incorrect? values have types variables do not ,in untyped languages isnt it?
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?


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). 

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

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

nice... :)

difference b/w type inference and dynamically typed language pls?
nice sushmita mam

@Arjun Isn't type casting makes option D false? Using type casting, variables can be associated with variables of different types.

6 votes

Detailed explanation on geeksforgeeks

This is an ambiguous question. “Untyped language” has no standard well-formulated definition, thus answering this question would be a bit difficult.

(A) Statically typed languages have one type associated to a variable, which is fixed once it has been deduced. Though, types could either be specified while code editing by the coder (Eg. C, Java), or it can be inferred at compile time (Eg. C++11, Haskell). Hence, after compile-time, every variable is bound to one fixed type, making this statement [TRUE]

(B) According to one definition, un-type languages store values in form of bits, thus neither variables nor values have any types associated to them. Hence this statement becomes [TRUE]

(C) Dynamically typed languages deduce types of values and bind them to the variables storing those values. Hence, values sure have fixed types, but variables don’t have fixed types bound to them. Although we can say that binding a type to a variable according to values makes them typeful, but they don’t have one fixed type. This statement has some ambiguity. [TRUE/FALSE]

(D) Same reason as of (A) [TRUE]

Hence, correct answer should be (C)

–1 vote
Answer is a.


what is type inferencing?
Type inference refers to the automatic detection of the data type of an expression in a programming language.

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