Important 2
Important 2
Course: Objective C
MCQ True/False
1- 1-
2- 2-
3- 3-
4- 4-
5- 5-
6- 6-
7- 7-
8- 8-
9- 9-
#import <Cocoa/Cocoa.h> #import <Foundation/Foundation.h>
# import "ClassA.h" @interface ClassA : NSObject{
int x;
int main(int argc, const char * }
argv[]) { -(void) methodA;
ClassA *obj = [ClassA new]; @end
[obj methodA];
@implementation ClassA
return 0; -(void) methodA{
} printf("this is method A\n");
Main.m }
@end
1- The above code: classA.h
A- Will print -> this is method A.
B- Generate compile time error both interface and implementation in one file.
C- Generate run time error as both interface and implementation in one file.
#import <Foundation/Foundation.h>
#import "Person.h"
@interface Person : NSObject #import "ClassA.h"
@end
2- The above code:
A- Will compile and run correctly.
B- Generate Compile time error “Conflicting super class name ‘ClassA’ ”.
C- Generate Run time error because the parent class in the implementation file is different.
#import "Person.h"
int main(int argc, const char *
#import <Foundation/Foundation.h>
argv[]) {
@interface Person : NSObject{
Person *p = [Person new];
int num;
p->num = 5;
}
@end
return 0;
}
3- The above code:
A- Will compile and run correctly.
B- Generate Compile time error.
C- Generate Run time error.
#import "Person.h"
int main(int argc, const char * #import <Foundation/Foundation.h>
argv[]) {
@interface Person : NSObject{
Person *p = [Person new]; @property int idNum;
p.idNum = 10; }
return 0; @end
}
4- The above code:
A- Will compile and run correctly.
B- Generate Compile time error “Unknown type name ‘property’”.
C- Generate Run time error.
[var1 release];
[var2 release];
[var3 release];
int x = self.myPro;
Best Luck.