def display_cat_details(color,name,pet_name=None):
print("Color:")
print(color)
print("Name:")
print(name)
if pet_name !=None:
print(pet_name)
Which of the following functions call will execute successfully?
Choose two correct options
a. display_cat_details(“Black”,”Roger”,”Snow”)
b. display_cat_details(“white”)
c. display_cat_details(“Grey”, pet_name=”Grey)
d. display_cat_details(“Brown”,”Nelly”)
Answer
a, d
Explanation
In this function, there are three parameters among them the last parameter is optional. In option b only one parameter is passed so it will not be a proper call. And in option c 2nd parameter which is necessary is not been passed so the wrong function call and a and d are proper function calls.
class Trainee:
def __init__(self):
self.id=1000
self.name="Tom"
self.__salary=1000
def view_details(self):
print("Trainee "+self.name+"has salary of " + str(self.__salary))
trainee=Trainee()
trainee.view_details()
Choose the Incorrect answer from the below options
a. view_details method has complete access to all attributes of class trainee
b. id of the trainee object can be changed outside the class trainee even if there is no setter for it.
c. salary of the trainee object can be displayed outside the class trainee using trainee.__salary
d. name of the trainee object can be displayed outside the class trainee without calling the view_details method
Answer
c
Explanation
self.__variablename is the syntax for private variable and so salary is a private variable hence it can not be accessed outside of the class
What will be the output of this code?
class Glove:
def __init__(self,color):
self.__color=color
def get_color(self):
return self.__color
def set_color(self,color):
self.__color=color
class Minion:
def __init__(self,glove):
self.__glove=glove
self.color="Pink"
def get_glove(self):
return self.__glove
violet_glove=Glove("Violet")
yellow_glove=Glove("Yellow")
bob=Minion(yellow_glove)
special_glove=violet_glove
yellow_glove.set_color(bob.color)
print(bob.get_glove().get_color())
a violet
b Pink
c Yellow
d Attribute Error:
Answer
b
Explanation
Yellow_globe color is changed with bob color which is pink so yellow_globe color becomes pink. Then in last line bob.get_glove() is actually the yellow_glove and yellow_glove.get_color() is pink now so pink is answer.
class Car:
__counter=100
types=['SUV','Hatchback','Coupe']
def __init__(self,model,doors):
self.model=model
self.doors=doors
self.color=None
car1=Car("Ford",4)
car2=Car("Porsche",2)
How many static variables, local variables, and instance variables are present in the given code snippet?
a. static=2 Local=2 instance =3
b. static=2 local 3 instance 3
c. static =1 local=3 instance=2
d. static=1 local=2 instance =2
Answer
a
Explanation
__counter and types are two static variable and model and doors are two local variable and model doors and color are three instance variable.
Consider the hash function below:
h(key) = key%7
Which values may have collision if any, when the following values are stored in the hash table
80 15 25 14 12 20 35 49
a.14 35 25
b. 14 35 49 80 25
c. No collision
d. 14 35 49
Answer
d
Explanation
In option d if we apply the hash function then output will be 0 for all the three numbers and hence it will collision.
Tom and peter have joined a university which offers two types of subjects- mandatory and optional. Each mandatory subject has an educator, grade, and classroom. Each optional subject has duration and grade. Every subject has an id and if the above scenario is to be implemented using an object-oriented approach, identify the most suitable implementation from the above options.
a 3 independent classes : Subject, MandatorySubject, OptionalSubject
b 3 classes: Subject as the parent class. MandatorySubject and OptionalSubject as child classes of subject
c 3 classes : Subject, MandatorySubject ,OptionalSubject . Subject aggregates mandatory subject and OptionalSubject.
d 3 classes: Subject as the parent class . OptionalSubject as the child class of subject . MandatorySubject as the child class of OptionalSubject.
Answer
b
What will be the Output of the below code?
class AdditionQuiz:
def __init__(self,num1,num2):
self.score=0
self.num1=num1
self.num2=num2
def evaluate_quiz(self,answer):
if self.num1+self.num2==answer:
self.score+=1
return "Good job"
return "Try Again"
def return_score(self):
return self.score
class MultiplicationQuiz(AdditionQuiz):
def evaluate_quiz(self,answer):
if self.num1+self.num2==answer:
self.score+=2
return " Well done"
elif answer%self.num1==0 or answer%self.num2==0:
self.score+=1
return " Better lucjk next time"
return "can do better"
add_quiz_obj=AdditionQuiz(14,2)
mul_quiz_obj= MultiplicationQuiz(2,7)
print(mul_quiz_obj.evaluate_quiz(16))
print("score:", mul_quiz_obj.return_score())
a. Try again
score: 0
b. Good job
Can do better
Score: 1
C. Better luck next time
Score: 1
d. Can do better
AttributeError: ‘MultiplicationQuiz’ object has no attribute
Answer
c
Explanation
In driver code, the second-line MultiplicationQuiz object has been made with value 2,7 and the second line evaluate_quiz is called with input 16. As 2+7=9 ins not equals to 16 and in second else if statement 16%2=0 so score will become 1 and Better Luck next time will be printed.
def dict_items(dict1):
global dict2
for key in dict1.keys():
dict2[key+1]=dict1[key]+key
dict1[key]=dict2[key+1]
dict2={}
dict_items({1:1,2:20,3:32,4:43,5:54})
a. dict1-{1:2,2:22,3:35,4:47,5:59}
dict2-{1:2,2:22,3:35,4:47,5:59}
b. dict1-{1:2,2:22,3:35,4:47,5:59}
dict2-{2:2,3:22,4:35,5:47,6:59}
c. dict1-{1:1,2:1,3:22,4:35,5:47,6:59}
dict2-{2:2,3:22,4:35,5:47,6:59}
d. dict1-{1:2,2:22,3:35,4:47,5:59}
dict2-{}
Answer
b
Explanation
The input dictionary to the function is 1:1, 2:20,3:32,…
For every time the loop executes the dict2 keys will start from 2 and the value will be the value of key-1 of the initial dictionary+key value means. dict2[2]=dict1[1]+1 so it becomes 2:2 in next iteration dict2[3]=dict1[2]+2so it becomes 3:22 and next line the value of dict1 updates as the same of dict2 but key is less than 1 so the output will be dict1 will start from key value 1 and dict2 will start from key value 2 but they will content same value accordingly means what will be the value of dict1[key] will be same value in dict2[key+1]
What will be the output of the code?
def dict_items(dict1):
global dict2
for key in dict1.keys():
dict2[key+1]=dict1[key]
dict1[key]=dict2[key+1]+key
dict2={}
dict_items({1:10,2:20,3:30,4:40,5:50})
print(dict2)
a. dict1 – {1:11 , 2:22 , 3:33 , 4:44 , 5: 55}
dict2 – {1:11 , 2:22 , 3:33 , 4:44 , 5: 55}
b. dict1 — {1:11 , 2:22 , 3:33 , 4:44 , 5: 55}
dict2 — {2:11 , 3:22 , 4:33 , 5:44 , 6: 55}
c. dict1 – {1:11 , 2:22 , 3:33 , 4:44 , 5: 55}
dict2 – {2:10 , 3:20 , 4:30 , 5:40 , 6: 50}
d. dict1 – {1: 11 , 2 : 11, 3: 22, 4 : 33 , 5 : 44 , 6 : 55}
dict2 – {2 :10, 3: 21, 4:30 ,5: 41, 6:50}
Answer
c
Explanation
Let’s try to understand the output of the dict2 first dict2 value is the same in all position like dict1 only the key is increased by 1 so the output is 2: 10, 3:20, 4:30 like this and dict1 value will be updated what will be the previous value will be added with the key-value by keeping all keys same as previous so 1:10 will become 1:10+1= 1:11 like this 2: 20 will become 2:20+2=2:22 like this.
- Unlocking Innovation and Diversity: Accenture HackDiva Empowers Women in Tech with Cutting-Edge Solutions – codewindow.in
- QA Engineer Opportunities at Siemens Company: Apply Now – codewindow.in
- QA Engineer Opportunities at Siemens Company: Apply Now – codewindow.in
- Software Engineer Positions at Siemens Company: Apply Now – codewindow.in
- Cloud Engineer II Opportunities at Insight Company: Apply Now – codewindow.in
- Shape Your Career: Assistant Engineer Opportunities at Jindal Company – codewindow.in
- Shape Your Future: Executive Opportunities at Jindal Company – cdewindow.in
- Associate Engineer, Software Development at Ingram: Apply Now – codewindow.in
- Jade Company’s UI/UX Development Engineer Opportunities – Apply Now – codewindow.in
- Transform Your Career with S&P Global: Apply for the Software Development Engineer Role and Lead the Future of Financial Technology Innovation – codewindow.in
- Unlock Your Potential at Accenture as an Associate Software Engineer – Elevate Your Career with Innovation and Excellence – codewindow.in
- Accelerate Your Career: Join NVIDIA’s Elite Software Engineering Internship Program and Shape the Future of Technology – codewindow.in
- C Programming Interview Questions – codewindow.in
- Lead the Way in Analytics: Specialist Position at Razorpay – codewindow.in
- Innovate with Cyient: Junior Software Engineer Wanted – codewindow.in
- Innovate with Volvo: Associate Software Engineer Wanted – codewindow.in
- Lead the Tech Revolution: Full Stack Developer at Unisys – codewindow.in
- Software Engineer at ABB: Unlock Innovation and Shape the Future – codewindow.in
- IBM Associate Systems Engineer Job: Boost Your Career with a Leading Technology Giant – codewindow.in
- Make Your Mark in Android Development: Join Concentrix – codewindow.in
- Infosys is Growing: Field Services Developer Role Now Open – codewindow.in
- Start Your IT Career Journey with Amazon: IT Services Support Associate I Opportunity – codewindow.in
- Shape the Future of Web: Front-End Software Engineer Opportunity at Google Cloud – codewindow.in
- Barclays QA Team Expands: QA Analyst Role Now Open- codewindow.in
- Eurofins QA Team Grows: Test Engineer Role Now Open – codewindow.in
- Exciting Opportunity: Java Spring Boot Senior Developer Role at Infosys – codewindow.in
- Unlock Your Potential at Nokia: Software Engineer Opportunities Await – codewindow.in
- Join Microsoft’s World-Class Team as a Software Engineer and Shape the Future of Technology – codewindow.in
- Virtusa is Seeking Talented React JS Developers to Drive Digital Excellence – codewindow.in
- Join IBM Dynamic Team as a Full Stack Developer and Shape the Future – codewindow.in
- EY Welcomes Aspiring AI/ML Interns to Unlock the Future of -codewindow.in
- Exciting Opportunity: Project Engineer at Rockwell Automation- codewindow.in
- Be at the Nexus of Technology & Finance: Associate Software Engineer at Goldman Sachs – codewindow.in
- Wipro is Hiring Test Engineers to Elevate Quality Assurance – codewindow.in
- Deloitte Is Hiring: Analysts and Senior Analysts Wanted to Drive Innovation – codewindow.in
- Exciting Software Development Opportunity At Oracle – codewindow.in
- BlackBerry Hiring System Software Developer – off campus – codewindow.in
- Lenskart hiring IT Support – off campus – codewindow.in
- Bold Hiring Software Engineer-UI – codewindow.in
- Myntra Hiring Software Engineer – off campus drive – codewindow.in
- PayPal Hiring Data Analyst 1 – codewindow.in
- SIEMENS HEALTHINEERS Hiring Data Scientist ( ML & AI) – codewindow.in
- RELX Digital hiring Software Engineer I – codewindow.in
- KPMG hiring Full Stack Developer Analyst – codewindow.in
- KPMG Hiring for Software Engineer – off Campus – codewindow.in
- Previous Year Coding Questions Suggestion Paper – codewindow.in
- Programming in C++ – codewindow.in
- Programming in C++ – codewindow.in
- Unstop Hiring Challenges Internships and Hackathons – codewindow.in
- Programming in Python – codewindow.in
- Adobe
- Advanced Coading
- Advanced course
- Ajax
- Algorithm
- Amagi
- Amazon Interview Questions
- Angular JS
- Aptitude
- Aptitude tricks
- Automata Fixing
- Basic Coding
- big data
- Books
- Bridge2i
- C programming
- Campgemini Interview Questions
- Capgemini Coding Questions
- Capgemini Pseudocode
- Celebal Tech
- Cloud Computing
- code nation
- Coding Questions
- Cognizant Placement
- commvault Systems
- Computer Network
- CSS
- CTS
- Data Science
- Data Structure
- Data Structure and Algorithm
- DBMS
- De Show Interview Questions
- deloitte
- Deutsche Bank Interview questions
- Enhance Communication
- Epam Full Question Paper
- Extempore
- Exxon Mobil interview questions
- filpkart
- Fractal Analytics Interview Questions
- Genpact
- Grab
- GreyB Interview Questions
- Group Discussion
- Guidance for Accenture
- Gupshup
- Hackathon 2024
- HCL Interview Questions
- Hexaware
- HFCL
- HR Questions
- HTML5
- IBM Interview questions
- IBM Questions
- Incture Interview Questions
- Infineon Technologies Interview Questions
- Infosys
- Infosys Interview Questions
- Internship
- Interview Experience
- Interview Questions
- ITC Infotech
- itron
- JavaScript
- JECA
- Job Info
- JQuery
- Kantar Interview Questions
- Language Confusion
- language confussion
- Larsen & Turbo
- Latenview AnalyticsInterview questions
- Lexmark International Interview Questions
- Machine Learning
- Media.net
- Mindtree Interview Questions
- Miscellaneous
- Mock Test Series
- MongoDB
- Morgan Stanly Interview Questions
- nagarro
- navi
- NodeJS
- NTT Data Interview Questions
- NVDIA
- NVDIA interview questions
- Operating System
- Optum
- PayU
- Persistent INterview Questions
- PHP and MYSQL
- Previous Coding Questions
- Programming in C
- Programming in C++
- Programming in JAVA
- Programming in Python
- Pseudo Code
- pseudocode
- PWC Interview Questions
- Python
- Quiz
- Razorpay
- ReactJS
- Recruiting Companies
- Revature
- salesforce
- Samsung
- Schlumberger
- Seimens
- Slice
- Smart Cube
- Software Engineering
- Study Material
- Tally Solutions
- tata cliq
- TCS
- TCS NQT
- TCS NQT Coding Questions
- Tech Mahindra Coding Questions
- Tech Mahindra Questions
- Technical Preparation
- Teg Analytics
- Tejas Network Interview Questions
- Texas Instrument Interview Questions
- Tiger Analytics
- Uncategorized
- UnDosTres
- Unstop
- Verbal Ability
- Verbal Lesson
- Web Development
- wipro
- Wipro Coding Questions
- Wipro interview Questions
- Wipro NLTH
- WIpro NLTH Coding Solve
- Zenser
- Zoho Interview Questions
- January 2024
- October 2023
- September 2023
- August 2023
- July 2023
- June 2023
- May 2023
- April 2023
- March 2023
- February 2023
- January 2023
- November 2022
- October 2022
- September 2022
- August 2022
- July 2022
- June 2022
- May 2022
- April 2022
- March 2022
- February 2022
- January 2022
- December 2021
- November 2021
- October 2021
- September 2021
- August 2021
- July 2021
- June 2021
- May 2021
- April 2021
- March 2021
- January 2021
- December 2020
- November 2020
- October 2020
- September 2020