write a code for this:trailer recordId contains a value
other than 99, then the file must error with the
reason ‘Invalid RECORD_ID’(User Defined Exception).



write a code for this:trailer recordId contains a value other than 99, then the file must error wi..

Answer / Bipin Gupta

Here's a Python code example that defines and uses a custom exception to handle invalid record IDs.nn```pythonnclass InvalidRecordIdError(Exception):n passndef process_file(file):n trailer = file.readline().strip()n match = re.search(r'^TRAILER:s*(d{2})$', trailer)n if not match or int(match.group(1)) != 99:n raise InvalidRecordIdError('Invalid RECORD_ID')n# rest of the file processing code...``

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More OOPS Interview Questions

i have to create a view in SQL as like in ORACLE DATA EXPRESS EDITION

2 Answers   CTS,


2. Give the different notations for the class.\

1 Answers  


What are the three main types of variables?

1 Answers  


What is the difference between the C & C++?

9 Answers   HCL,


why to use operator overloading

3 Answers  


#include <iostream> using namespace std; int main() { int a = 3; int c[5][5]; for (int x=0;x<5;x++) { for (int y=0;y<5;y++) { c[x][y] = x*y; } } cout << c[a][2]; }

1 Answers  


why the memory allocated with new cant be freed using free()

2 Answers  


When a private constructer is being inherited from one class to another class and when the object is instantiated is the space reserved for this private variable in the memory??

13 Answers   HCL, Honeywell,


Explain the concept of abstracion and encapsulation with one example. What is the difference between them?

3 Answers   PCS,


Why do we use polymorphism?

1 Answers  


write a program using c++ to implement single contiguous memory mangement techniques.display the content of the main memory after yhe allocation of jobs and percentage of the wastage of the main memory

1 Answers  


write a code for this:trailer recordId contains a value other than 99, then the file must error with the reason ‘Invalid RECORD_ID’(User Defined Exception).

1 Answers  


Categories