3、
NSDictionary *dict = [NSDictionary dictionaryWithObject:@"a value" forKey:@"aKey"];
NSLog(@"%@",[dict objectForKey:@"aKey"]);
[dict release];
控制台中打印的最后一条信息会是:

答案:(C)

22、
对于Objective-C中的方括号“[]”的作用,下列说法错误的是:

答案:(D)

26、
NSString *name = [[NSString alloc]initWithString:@"张三"];
NSLog(@"%d",[name retainCount]);
上述代码打印结果是:

答案:(A)

30、
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)

31、
关于NSSet描述正确的有:

答案:(B)

37、
现要求声明一个集合,并将字符串添加到集合中,编写了如下代码,其中错误的是第几行:
NSString * aString = [[NSString alloc] initWithString:@"iLanou"]; (1)
[aString autorelease]; (2)
NSArray * arr = [NSArray array]; (3)
[arr addObject:aString]; (4)
NSLog(@"string = %lu",[aString retainCount]);

答案:(C)

39、
下面程序段的输出结果是什么:
NSArray * arr1 = [[NSArray alloc] initWithObjects:@"1",@"2",@"3", nil];
NSString *str;
str = [arr1 objectAtIndex:2];
NSLog(@"%@",str);

答案:(C)

46、
以下对类的描述不正确的是:

答案:(C)

53、
声明一个返回值为NSArray,并且带两个字符串对象的BLOCK类型变量:

答案:(D)

66、
下面程序段的输出结果是什么:
NSString * aString = [[NSString alloc] initWithString:@"hehe"]; 
[aString autorelease];
NSMutableArray *arr = [NSMutableArray array];
[arr addObject:aString];
NSLog(@"string = %d",[aString retainCount]);

答案:(A)

68、
下列选项中不能正常为emp的name属性赋值的代码有:

答案:(B)

69、
写出下面程序段的输出结果:
NSString * aString = [[NSString alloc] initWithString:@"123"]; 
[aString autorelease];
NSMutableArray * arr = [NSMutableArray array];
[arr addObject:aString];
NSLog(@"string = %lu",[aString retainCount]);

答案:(C)

70、
NSMutableDictionary * dic = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"1",@"2",@"2",@"3",@"3",@"4", nil];
NSArray *arr = [[NSArray alloc] initWithArray:[dic allKeys]];
NSString *str = [[NSString alloc] initWithFormat:[arr objectAtIndex:0],[arr objectAtIndex:1],[arr objectAtIndex:2]];
NSLog(@"%@",str);
结果是:

答案:(C)

71、
下面程序段的输出结果是什么:
NSMutableDictionary * dic = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"1",@"2",@"1",@"3",@"1",@"4", nil];
NSArray *arr1 = [[NSArray alloc] initWithArray:[dic allKeys]];
NSArray *arr2 = [[NSArray alloc] initWithArray:[dic allValues]];
NSMutableDictionary *dic2 = [[NSMutableDictionary alloc] initWithObjects:arr1 forKeys:arr2];
NSLog(@"%@",dic2);

答案:(C)

  • 下面程序段的输出结果是什么:
    NSMutableDictionary * dic = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"1",@"2",@"2",@"3",@"3",@"4", nil];
    [dic setObject:@"1" forKey:@"3"];
    [dic removeObjectForKey:@"1"];
    NSLog(@"%@",dic);

    答案:(C)

78、
下面程序段的输出结果是什么:
NSString * aString = [[NSString alloc] initWithFormat:@"123"]; 
NSLog(@"%d",aString.retainCount);
aString = @"456";
NSLog(@"%d",aString.retainCount);
[aString release];
aString = @"789";
NSLog(@"%d",aString.retainCount);

答案:(D)

80、
查看下列代码,能正确输出number的选项是:
  @interface MyClass : NSObject
{
  int number;
}
+(void) printNumber;
@end
@implementation MyClass
+(void) printNumber
{
  number =10;
  NSLog(@""%d"",number);
}
@end

答案:(D)

 posted on 2015-03-14 16:28  一米深蔚蓝  阅读(510)  评论(0编辑  收藏  举报