OC测试题
一、选择题(共80题,每题1分)
1、不会立刻使引用计数器改变的是:_________ A、release B、alloc C、autorelease D、retain
2、在OC中类的接口声明关键字为:_________ A、@import B、@interface C、@implemention D、@protocol 3、
NSString *name = [[NSString alloc]initWithString:@\张三\
NSLog(@\上述代码打印结果是:_________ A、-1 B、0 C、1
D、2
4、下列选项中全部属于对象的是:_________ A、我的白色iPhone4s;Mac Mini B、狗;老虎
C、邻居家的猫咪“贝贝”;我的弟弟“张三” D、保时捷;犀利哥 5、
NSDictionary *dict = [NSDictionary
dictionaryWithObject:@\NSLog(@\[dict release];
控制台中打印的最后一条信息会是:_________ A、a value B、aKey : a value C、崩溃信息 D、a value : aKey
6、现有如下集合,能准确删除“张三”的代码是:NSMutableDictionary * peoples=[NSMutableDictionary dictionaryWithObjectsAndKeys:@\张三\左护法\李四\右使\唐sir\老大哥\答案_________
A、[peoples removeObjectForKey:@\左护法\
B、[peoples removeObject:@\张三\C、[peoples removeObjectAtIndex:0]; D、[peoples removeAllObjects];
7、关于类和对象的概念,下列属于对象的是:_________ A、奥迪A6 B、保龄球 C、世界冠军刘翔 D、西红柿
8、以下说法不正确的是:_________
A、nonatomic:提供多线程保护,提高性能,在没有使用多线程的编程中可以选择使用。
B、assign:属性默认值。说明设置器直接进行赋值,针对基础数据类型(NSInteger,CGFloat)和C数据类型(int, float, double, char)等等。
C、retain:此属性只用于obj-c的对象类型,对参数进行release旧值,再retain新值。
D、copy:此属性只对实现NSCopying协议的对象有效(NSString)。拷贝工作由copy方法执行。 9、
NSArray *array = [NSArray
arrayWithObjects:@\NSMutableSet *set = [[NSMutableSet alloc]init];
for(NSString *str in array){ [set addObject:str];}
NSLog(@\控制台打印的结果是:__________ A、4 B、5 C、6 D、7
10、经过下列哪种操作后需要使用release方法。答案________ A、delegate B、assign C、retain D、dealloc
11、声明一个方法:提供Student对象数组按照学号升序排列的判断条件:答案: A、
-(NSComparisonResult)compareWithNumberForAscendSort:(Student*)otherStudent B、
-(NSInteger)compareWithNumberForAscendSort:(Student*)otherStudent
C、-
(BOOL))compareWithNumberForAscendSort:(Student*)otherStudent
D、+(int)compareWithNumberForAscendSort:(Student 12、下列哪个选项不需要release方法: 答案:
A、[[NSString alloc]init];
B、[[NSString alloc] initWithString:@”hehe”]; C、[[NSArray arrayWithArray: arr1]; D、[[NSMutableDictionary alloc] init]; 13、OC中,所有类的根类是: 答案: A、NSObject B、NSDate C、NSCoding D、UIView
14、下列哪个选项与@synthesize配合使用: 答案: A、@end B、@interface C、@implementation D、@property