Home>IT Tests>Questions>What is the output of the following Objective-C code?
@interface MyClass : NSObject
- (void)doSomething;
@end
@implementation MyClass
- (void)doSomething {
NSLog(@"%@", self);
}
@end
int main(int argc, const char * argv[]) {
MyClass *myClass = [[MyClass alloc] init];
[myClass doSomething];
return 0;
}
Question from the Objective-C test
What is the output of the following Objective-C code? @interface MyClass : NSObject - (void)doSomething; @end @implementation MyClass - (void)doSomething { NSLog(@"%@", self); } @end int main(int argc, const char * argv[]) { MyClass *myClass = [[MyClass alloc] init]; [myClass doSomething]; return 0; }
Medium
What happens in the runtime when you send a message to nil?
Author: Smart&SoftStatus: PublishedQuestion passed 19 times
Edit
0
Community EvaluationsNo one has reviewed this question yet, be the first!
1
What is the keyword to use to avoid retain cycles in Objective-C?0
What is the default value of an uninitialized Objective-C variable?0
What is the Objective-C keyword to make a property private?0
How to throw an exception in Objective-C0
What is the superclass of UIViewController?0
What is the type of the result of the following expression? '2023-03-08 12:00:00 +0000'.dateWithFormat('yyyy-MM-dd HH:mm:ss Z')0
Objective-C code that compiles and runs.