●测试题及讲解

作者: 小猪也浪漫 | 来源:发表于2016-01-05 21:11 被阅读223次

    ※ 选择题(共25题,每题3分)

    
            1、以下对响应链说法错误的是:答案:(A)
            A、当事件发生的时候,响应链首先被发送给第一个响应者
            B、事件将沿着响应者链一直向下传递,直到被接受并作出处理
            C、如果整个过程都没有响应这个事件,则该事件最终要由APP Delegate做出处理
            D、一般情况下,在响应链中只要有对象处理事件,事件就会被传递
        #1.解析:一个典型的相应路线图如:First Responser -- > The Window -- >The Application -- > App Delegate
    
            2、以下对多线程开发的理解错误的是:答案:(C)
            A、发挥多核处理器的优势,并发执行让系统运行的更快、更流畅,用户体验更好
            B、多线程程序中,一个进程包含2个以上的线程(含2个)
            C、大量的线程降低代码的可读性,但不需要更多的内存空间
            D、当多个线程对同一个资源出现争夺的时候要注意线程安全的问题
        # 2.解析:大量的线程降低代码的可读性,需要更多的内存空间,
                      
            3、实现一个生成Student实例对象的便利构造器的正确写法是:答案:(A)
            A、+ (id)studentWithName:(NSString *)newName andAge:(int)newAge
            {
              Student *stu = [[[Student alloc] initWithName:newName andAge:newAge] autorelease];
              return stu;
            }
            B、 - (id)studentWithName:(NSString *)newName andAge:(int)newAge
            {
              Student *stu = [[Student alloc] initWithName:newName andAge:newAge];
              return [stu autorelease];
            }
            C、 - (void)studentWithName:(NSString *)newName andAge:(int)newAge
            {
              Student *stu = [[Student alloc] initWithName:newName andAge:newAge];
              return [stu autorelease];
            }
            D、 + (void)studentWithName:(NSString *)newName andAge:(int)newAge
            {
              Student *stu = [[Student alloc] initWithName:newName andAge:newAge];
              return [stu autorelease];
            }
               
         # 3.解析:便利构造器必须是类方法(+方法);而且必须手动释放内存
                     
    
            4、获取tableview正在window上显示的cell的indexPath方法是:答案:(B)
            A、- (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath;
            B、- (NSArray *)indexPathsForVisibleRows;
            C、- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
            D、- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath;
      # 4.解析:熟悉UITableView的相关代理方法
    
            5、下面关于深拷贝与浅拷贝理解正确的是:答案:(A)
            A、深拷贝拷贝的是内容,浅拷贝拷贝的是指针。
            B、深拷贝和浅拷贝最大的区别就是子类对象的地址是否改变。
            C、深拷贝是对对象本身复制,但是不对对象的属性进行复制。
            D、如果子类对象的地址改变那么就是深拷贝。
      # 5.解析:深拷贝拷贝的是内容,浅拷贝拷贝的是指针
    
            6、关于OC内存管理方面说法错误的是:答案:(B)
            A、OC中的内存管理采用引用计数机制
            B、autorelease pool 是OC中一种自动的垃圾回收机制
            C、alloc、new或copy来创建一个对象,那么你必须调用release或autorelease
            D、OC的内存管理机制本质上还是C语言中的手动管理方式,只不过稍加了一些自动方法
      # 6.解析:自动释放池(Autorelease pool)是OC的一种内存自动回收机制,可以将一些临时变量通过自动释放池来回收统一释放。自动释放池本事销毁的时候,池子里面所有的对象都会做一次release操作  
    
            7、以下的代码会出现什么问题:
            @implementation Person
            - (void)setAge:(int)newAge {
              self.age = newAge;
            }
            @end答案:(B)
            A、会造成循环引用
            B、会造成死循环
            C、会出现内存泄露
            D、会出现野指针
      # 7。解析:点语法一般调用的是set或者get方法,此处出现了循环调用
    
            8、对于UIScrollViewController,scrollView将开始降速时,执行的方法是:答案:(D)
            A、- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView;{ }
            B、- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;{ }
            C、- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView;{ }
            D、- (void)scrollViewWillBeginDecelerating:
      # 8.解析:熟悉UIScrollView的代理方法
    
            9、以下哪个控件不是继承于UIControl答案:(D)
            A、UIButton
            B、UITextField
            C、UISlider
            D、UITextView
      # 9.解析:UITextView(可滑动)继承UIScrollView;
    
            10、下面对UIView、UIWindow和CALayer理解错误的是:答案:(C)
            A、UIView继承于UIResponder
            B、UIResponder继承于NSObject,UIView可以响应用户事件。
            C、UIResponder继承与NSObject,CALayer继承于NSObject,CALayer可以响应事件。
            D、UIView是用来显示内容的,可以处理用户事件,CALayer是用来绘制内容的,依赖与UIView来进行显示
    
      # 10.解析:CALayers 是屏幕上的一个具有可见内容的矩形区域,每个UIView都有一个根CALayer,其所有的绘制(视觉效果)都是在这个layer上进行的
            11、以下关于视图的frame与bounds的理解错误的是:答案:(A)
            A、bounds是指这个view在window坐标系的坐标和大小
            B、frame指的是这个view在它superview的坐标系的坐标和大小
            C、frame和bounds是UIView中的两个属性(property)。
            D、一个是以自身左上角的店为原点的坐标系,一个是以屏幕左上角的点为原点的坐标系。
      # 11.解析:bounds是一个是以自身左上角的店为原点的坐标系
            12、以下哪个方法在当程序将要退出时被调用,且通常在此方法里写一些用来保存数据和一些退出前的清理工作。答案:(B)
            A、- (void)applicationExitsOnSuspend:(UIApplication *)application{ }
            B、- (void)applicationDidEnterBackground:(UIApplication *)application{ }
            C、- (void)applicationWillTerminate:(UIApplication *)application{ }
            D、- (void)applicationDidFinishLaunching:(UIApplication *)application{ }
      # 12.解析:自行了解
    
            13、很多内置类如UITableViewController的delegate属性都是assign而不是retain,这是为了:答案:(D)
            A、防止造成内存泄露
            B、防止出现野指针
            C、防止出现过度释放
            D、防止循环引用
      # 13.解析:防止循环调用
    
            14、以下不属于ios中实现多线程的方法是:答案:(D)
            A、NSThread
            B、NSOperationQueue
            C、Grand Central Dispatch(GCD)
            D、NSURLRequest
      # 14.解析:NSURLRequest是网络请求
    
            15、对于UISearchBar,要实现实时搜索(即搜索内容实时发生变化时),会执行以下哪个方法:答案:(C)   (自己查询)
            A、- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar;
            B、- (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar;
            C、- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{ }
            D、- (void)searchBarResultsListButtonClicked:(UISearchBar *)searchBar{ }
      # 15.解析:见名知意
    
            16、以下关于导航栏外观属性对应的解释错误的是:答案:(D)
            A、barStyle bar的样式
            B、translucent bar的透明度
            C、backgroundImage bar的背景图片
            D、barTintColor bar上控件的颜色
      # 16.解析:barTintColor  渲染颜色
            17、当程序从后台将要重新回到前台的时候,会先执行以下哪个方法:答案:(B)
            A、- (void)applicationDidFinishLaunching:(UIApplication*)application{ }
            B、- (void)applicationWillEnterForeground:(UIApplication *)application{ }
            C、- (void)applicationDidBecomeActive:(UIApplication *)application{ }
            D、 - (void)applicationWillTerminate:(UIApplication *)application{ }
      # 17.解析:Foreground前台
            18、实现一个singleton的类,下面正确的是:答案:(A)
            A、static LOSingleton * shareInstance == nil;
            + ( LOSingleton *)sharedInstance{
             @synchronized(self){
              if (shareInstance == nil) {
               shareInstance = [[self alloc] init];
              }
             }
             return shareInstance;
            }
            
            B、static LOSingleton * shareInstance;
            - ( LOSingleton *)sharedInstance{
             @synchronized(self){
              if (shareInstance == nil) {
               shareInstance = [[self alloc] init];
              }
             }
             return shareInstance;
            }
            
            C、+ (LOSingleton *) sharedInstance
            {
             LOSingleton *sharedInstance = nil ;
             static dispatch_once_t onceToken;  
             dispatch_once (& onceToken, ^ {  
              sharedInstance = [[self alloc] init];
             });
             return sharedInstance;
            }
            
            D、- (LOSingleton *) sharedInstance
            {
             static LOSingleton *sharedInstance = nil ;
             static  dispatch_once_t onceToken;  
             dispatch_once (& onceToken, ^ {  
              sharedInstance = [[self alloc] init];
             });
             return sharedInstance;
            }
              # 18.解析:1.单例是个类方法(+方法)2.static LOSingleton *sharedInstance == nil ;必须使用static修饰
    
            19、当应用程序将要进入非活动状态执行,在此期间,应用程序不接收消息或事件,比如来电话了,此时会先执行以下哪个方法:答案:(D)
            A、- (void)applicationDidBecomeActive:(UIApplication *)application{ }
            B、- (void)applicationDidEnterBackground:(UIApplication *)application{ }
            C、- (void)applicationWillTerminate:(UIApplication *)application{ }
            D、- (void)applicationWillResignActive:(UIApplication *)application{ }
      # 19.解析:D是程序即将结束活跃状态
                       //   程序的启动流程
            20、应用程序启动顺序正确的是:
            ①在UIApplication代理实例中重写启动方法,设置第一个ViewController
            ②程序入口main函数创建UIApplication实例和UIApplication代理实例
            ③在第一个ViewController中添加控件,实现对应的程序界面。 答案:(B)
            A、①②③
            B、②①③
            C、①③②
            D、③①②
      # 20.解析:应用程序启动顺序:首先是Mian函数
                     
                      //  UICollectionViewController 集合视图的代理
            21、对于UICollectionViewController,实现定义每个元素的margin(边缘 上-左-下-右) 的方法是:答案:(B)
            A、- (CGSize)collectionView:(UICollectionView *)collectionView
             layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
            {  
             return CGSizeMake();  
            }
            B、- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView
             layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
            {  
             return UIEdgeInsetsMake();  
            }
            C、- (CGSize)collectionView:(UICollectionView *)collectionView
             layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
            {      
             return CGSizeMake();  
            }
            D、- (CGSize)collectionView:(UICollectionView *)collectionView
             layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section
            {  
             return CGSizeMake();  
            }
    #21.解析:边缘 上-左-下-右,只有B是四个参数
                     //  contentInset  设置UIScrollView边框(上 、左、下、右)
            22、以下对于UIScrollView的属性,说法错误的是:答案:(D)
            A、bounces 控制控件遇到边框是否反弹
            B、pagingEnabled 控制控件是否整页翻动
            C、scrollEnabled 控制控件是否能滚动
            D、contentInset 滚动范围大小
    
            23、对于UIScrollViewController,监控目前滚动的位置的属性是:答案:(A)
            A、contentOffSet 
            B、contentSize   
            C、contentInset 
            D、scrollIndicatorInsets
      # 23.解析:1.contentOffSet  // 当前滚动区域  contentSize   //  UIScrollView可滚动区域
    
            24、在MVC框架中,M与C通讯,通常使用什么方式?答案:(A)
            A、KVO与通知    
            B、协议-代理   
            C、类目
            D、属性
      # 24.解析:M--C通讯(KVO与通知)   C--V通讯(协议-代理 )
            25、对于UILabel,设置单词折行方式的属性是:答案:(B)
            A、textAlignment  
            B、lineBreakMode   
            C、numberOfLines  
            D、sizeToFit
      # 25.解析:textAlignment    //  字体对齐方式       numberOfLines   // 显示行数,如果为0,自动换行
    ※ 判断题(共5题,每题5分)
    
            1、UISlider、UISwitch、UITextField这些类都继承于UIControl这个类。答案:(T)
            正确
            错误
      # 26.解析:
    
            2、[textField resignFirstResponder]; 表示让文本输入框成为第一响应者, 弹出键盘进入编辑模式。答案:(F)
            正确
            错误
      # 27.解析:[textField resignFirstResponder]; 表示让文本输入框取消第一响应者                 
                        //  出栈入栈
            3、[self.view popToViewController: animated: YES];表示弹出一个视图控制器,到指定视图控制器上。答案:(F)
            正确
            错误
      # 28.解析:push进栈,pop出栈
                       
            4、numberOfTapsRequired这个方法能获取到的是有几只手指点击。答案:(F)
            正确
            错误
      # 29.解析: // numberOfTapsRequired 轻怕几次
                           
            5、[segmentedControl titleForSegmentAtIndex: ]表示指定索引文字的选项。答案:(T)
            正确
            错误
      # 30.解析:正确
    

    相关文章

      网友评论

      本文标题:●测试题及讲解

      本文链接:https://www.haomeiwen.com/subject/iweihttx.html