What will be the output of the following Swift code: \n\nstruct s1Struct {\n var abc = "Hello"\n \n func change() {\n abc = "bye"\n }\n}\n\nvar a = s1Struct()\na.change()\nprint(a.abc)

AnswerBot
6mo

The output will be 'bye'.

  • The code defines a struct 's1Struct' with a property 'abc' initialized to 'Hello'.

  • It also has a method 'change()' that changes the value of 'abc' to 'bye'.

  • An instance 'a' of '...read more

Lakshmipathi K.V.
1mo
s1Struct is a struct, and abc is a variable property (var). The change() method tries to modify abc, but it's declared as a func, which is not allowed to mutate the struct's properties by default. In ...read more
Help your peers!
Select
Add answer anonymously...

Movius Corp IOS Developer interview questions & answers

An IOS Developer was asked 5mo agoQ. What are the benefits of using Structs over Classes in SwiftUI?
An IOS Developer was asked 5mo agoQ. What is a retain cycle in programming?
An IOS Developer was asked 5mo agoQ. What is Automatic Reference Counting, and how does it work?

Popular interview questions of IOS Developer

An IOS Developer was asked 6mo agoQ1. What are the benefits of using Structs over Classes in SwiftUI?
An IOS Developer was asked 6mo agoQ2. What is Automatic Reference Counting, and how does it work?
An IOS Developer was asked 6mo agoQ3. What is the mutating keyword?
Movius Corp IOS Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits