- 1
- 2
- 3
- …
- 20
- Next Page »
A Learning Portal from Recruitment India
What is the biggest reason for the use of polymorphism?
It allows the programmer to think at a more abstract level
There is less program code to write
The program will have a more elegant design and will be easier to maintain and update
Program code takes up less space
Answer with explanation
Answer: Option CExplanation
Polymorphism allows for the implementation of elegant software.
Workspace
Which of the following is false about protected class members?
They begin with one underscore
They can be accessed by subclasses
They can be accessed within a class
They can be accessed by name mangling method
Answer with explanation
Answer: Option DExplanation
Protected class members can’t be accessed by name mangling
Workspace
To read the entire remaining contents of the file as a string from a file object infile, we use ____________
infile.read(2)
infile.read()
infile.readline()
infile.readlines()
Answer with explanation
Answer: Option BExplanation
read function is used to read all the lines in a file.
Workspace
What will be the output of the following Python code?
def c(f):
def inner(*args, **kargs):
inner.co += 1
return f(*args, **kargs)
inner.co = 0
return inner
@c
def fnc():
pass
if __name__ == ‘__main__’:
fnc()
fnc()
fnc()
print(fnc.co)
4
3
1
Answer with explanation
Answer: Option BExplanation
The code shown above returns the number of times a given function has been called. Hence the output of this code is: 3
Workspace
The formatting method {1:<10} represents the ___________ positional argument, _________ justified in a 10 character wide field.
second, right
first, left
second, left
first, right
Answer with explanation
Answer: Option CExplanation
The formatting method {1:<10} represents the second positional argument, left justified in a 10 character wide field.
Workspace