GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
218 views
Which of the following is a checked dynamic semantic error in C?
A. Use of uninitialized variable
B. Access off the end of an array
C. wrong number of parameters passed to a function
D, Divide by zero

In my opinion B is correct answer, But D is given in solution
asked in Compiler Design by Veteran (15.4k points)   | 218 views

3 Answers

+1 vote
Best answer

there are 2 types of exceptions
1)checked- the classes which extends "Exception" class are called checked exceptions
2)unchecked- the classes which extends "runtimeexception" class are called unchecked exceptions
optionB arrayIndexOutOfBounds class extends RunTimeException class hence its unchecked 
optionD dividedByZero class extends "Exception" class hence its checked.
so option is D

ref:https://www.google.co.in/search?sourceid=chrome-psyapi2&ion=1&espv=2&ie=UTF-8&q=checked%20vs%20unchecked%20exception&oq=checked%20vs%20&aqs=chrome.0.0j69i57j0l4.4262j0j4
ref:http://way2java.com/tag/array-index-out-of-bounds-exception/

answered by Veteran (11.6k points)  
selected by
@vijay How can we answer on basis of JAVA a C question?? C have no classes concept. Here option b and d both should be correct in context to C language.
as they specifically mentioned abt "checked" i answered that way
+1 vote

Checked: are the exceptions that are checked at compile time.

Unchecked are the exceptions that are not checked at compiled time. Means at run time

Access off the end of an array- happen at runtime

Divide by zero -happen at copile time

 

answered by (387 points)  
Perfect!
0 votes
acess to an array out of bound willl give me an garbage value so i think its not an semantic error random acess to array is possible so option b is wrong option d is semantic error becouse divide by zero does not sound meaning full expression so it is semantic error
answered by Active (2k points)  


Top Users Sep 2017
  1. Habibkhan

    6362 Points

  2. Warrior

    2234 Points

  3. Arjun

    2212 Points

  4. nikunj

    1980 Points

  5. manu00x

    1726 Points

  6. SiddharthMahapatra

    1718 Points

  7. Bikram

    1716 Points

  8. makhdoom ghaya

    1660 Points

  9. A_i_$_h

    1528 Points

  10. rishu_darkshadow

    1512 Points


25,988 questions
33,561 answers
79,406 comments
31,026 users