OC试题-2..docxVIP

  • 18
  • 0
  • 约1.46万字
  • 约 28页
  • 2016-12-10 发布于重庆
  • 举报
OC试题-2.

Objective-C考试 ※ 选择题(共80题,每题1分)1、OC中与alloc相反的方法是:答案:(C) A、release B、retain C、dealloc D、free2、必须实现的协议方法使用:关键字声明.答案:(C) A、@property B、@interface C、@required D、@protocol3、NSArray *array = [NSArray arrayWithObjects:@1,@2,@3,@4,@2, nil];NSMutableSet *set = [[NSMutableSet alloc]init];for(NSString *str in array){?[set addObject:str];}NSLog(@%lu,[set count]);[set release];控制台打印的结果是:答案:(A) A、4 B、5 C、6 D、74、声明一个方法:提供Student对象数组按照学号升序排列的判断条件:答案:(A) A、-(NSComparisonResult)compareWithNumberForAscendSort:(Student*)otherStudent B、-(NSInteger)compareWithNumberForAscendSort:(Student*)otherStudent C、- (BOOL))compareWithNumberForAscendSort:(Student*)otherStudent D、+(int)compareWithNumberForAscendSort:(Student5、下列选项中全部属于对象的是:答案:(C) A、我的白色iPhone4s;Mac Mini B、狗;老虎 C、邻居家的猫咪“贝贝”;我的弟弟“张三” D、保时捷;犀利哥6、关于集合描述不正确的是:答案:(A) A、所有的集合都可以添加元素。 B、集合分为可变集合、不可变集合。 C、数组、字典、NSSet这三种集合存储数据的方式不同。 D、所有集合都能保存id类型数据。7、NSDictionary *dict = [NSDictionary dictionaryWithObject:@a value forKey:@aKey];NSLog(@%@,[dict objectForKey:@aKey]);[dict release];控制台中打印的最后一条信息会是:答案:(C) A、a value B、aKey : a value C、崩溃信息 D、a value : aKey8、向Xcode控制台输出一个字符串应该用:答案:(A) A、NSLog() B、Printf() C、NSPrintf() D、scanf()9、名为print::的方法有几个传入参数:答案:(C) A、0 B、1 C、2 D、310、下列哪个选项与@synthesize配合使用:答案:(D) A、@end B、@interface C、@implementation D、@property11、面向对象的特性不包括:答案:(D) A、封装 B、继承 C、多态 D、构造12、OC中,所有类的根类是:答案:(A) A、NSObject B、NSDate C、NSCoding D、UIView13、现有如下集合,能准确删除“张三”的代码是:NSMutableDictionary * peoples=[NSMutableDictionary dictionaryWithObjectsAndKeys:@张三,@左护法,@李四,@右使,@唐sir,@老大哥, nil];答案:(A) A、[peoples removeObjectForKey:@左护法]; B、[peoples removeObject:@张三]; C、[peoples removeObjectAtIndex:0]; D、[peoples removeAllObjects];14、使用 Objective-C 语言输出“This is a Objective-C program.”正确的是:答案:(D) A、NSLog(@%s,This is a Objective-C program.); B、NSLog(@%@,This is a Objective-C program.); C、NSLog(@This is a Objective-C program.,%@); D、NSLog(@This is a Objective-C program.);15、下列说法中错误的是:答案:(C) A、Objective-C不用函数调用,而用互相传递讯息. B、Objective-C一个完整的类分为interface和implementat

文档评论(0)

1亿VIP精品文档

相关文档