UGC NET JULY 2018 (Computer Science And Applications Paper-II) (Question 7-9)
Q7. Which of the following statement is/are true ?
P: C programming language has a weak type system with static types.
Q: Java programming language has a strong type system with static types.
Code :
(1). P only (2). Q only
(3). Both P and Q only (4). Neither P nor Q
Answer : (3). Both P and Q only
Reason: Now in this question first of all we should have the knowledge or idea about words
dynamic/static types which means that the type information acquired at run time or compile time.
The static types checked at compile time and dynamic types checked at run time.
Secondly we also need information about weak/strong types means weather language tries to do implicit conversion from one type to another type.
The strong types means No implicit conversion and weak types means implicit conversion is allowed.
What makes a type system weak or strong comes down to a the ways in which the programmer is able to create type errors.
Now the C language is consider as weak typed because a programmer is allowed to cast types. I can add a pointer to a character if I just tell C that they are both integers.
Q7. Which of the following statement is/are true ?
P: C programming language has a weak type system with static types.
Q: Java programming language has a strong type system with static types.
Code :
(1). P only (2). Q only
(3). Both P and Q only (4). Neither P nor Q
Answer : (3). Both P and Q only
Reason: Now in this question first of all we should have the knowledge or idea about words
dynamic/static types which means that the type information acquired at run time or compile time.
The static types checked at compile time and dynamic types checked at run time.
Secondly we also need information about weak/strong types means weather language tries to do implicit conversion from one type to another type.
The strong types means No implicit conversion and weak types means implicit conversion is allowed.
What makes a type system weak or strong comes down to a the ways in which the programmer is able to create type errors.
Now the C language is consider as weak typed because a programmer is allowed to cast types. I can add a pointer to a character if I just tell C that they are both integers.
int main () {
char ch = 'b';
void *x;
(int)ch + (int)x;
}
Java has static type casting as well which allows the programmer to, for
example, downcast objects. This makes the static type system not sound.
But Java has dynamic type checking for just this reason. Yes, Java has
dynamic and static type checking. For this reason, however, I think many
people would consider Java to be strongly typed.
0 comments:
Post a Comment