Test introduction

I’ve been doing a master class for a while and I took a quiz with three purposes. It’s a lot of money. It’s recorded here

🎯 tests your recent studies

🎯 sounded the alarm, I hope we can correct the attitude of learning, timely check the leak to fill the gaps

🎯 Adjust the speed and depth of the lectures in the next stage according to your learning in this stage

The normal exam is divided into four types of questions. Out of 200 (don’t ask me why it wasn’t 100, eh… Is play!!!!!!!!!! 😸)

  • 1. Multiple choice questions (5 points for each question, 50 points for 10 questions in total)

  • 2, True or false (5 points per question, 30 points in total)

  • 3. Simple questions (10 points for each question)

  • 4, expand full score (20 points)

Below I post a question, if you have time, might as well also take a pen to test, see how many points can do, in the article message I will send you the answer at the first time! Or add me on wechat: KC_Cooci

A, multiple choice question (each question 5 points) ⚠️ have single choice have multiple choice oh ⚠️

    1. Under LP64, the number of bytes in a pointer is worth 5 points
  • A: 4

  • B: 8

  • C: 16

  • D: 64

    1. Which elements exist in the memory structure of an instance object score 5 points
  • A: member variable

  • B: supClass

  • C: cache_t

  • D: bit

    1. The followingsizeof(struct3)The size is equal to the value of 5 points
struct LGStruct1 {
    char b;
    int c;
    double a;
    short d;
}struct1;

struct LGStruct2 {
    double a;
    int b;
    char c;
    short d;
}struct2;


struct LGStruct3 {
    double a;
    int b;
    char c;
    struct LGStruct1 str1;
    short d;
    int e;
    struct LGStruct2 str2;
}struct3;
Copy the code
  • A: 48

  • B: 56

  • C: 64

  • D: 72

    1. The following code:re1 re2 re3 re4 re5 re6 re7Re8 Output results score 5 points
BOOL re1 = [(id)[NSObject class] isKindOfClass:[NSObject class]];     
BOOL re2 = [(id)[NSObject class] isMemberOfClass:[NSObject class]];   
BOOL re3 = [(id)[LGPerson class] isKindOfClass:[LGPerson class]];     
BOOL re4 = [(id)[LGPerson class] isMemberOfClass:[LGPerson class]];  
NSLog(@" re1 :%hhd\n re2 :%hhd\n re3 :%hhd\n re4 :%hhd\n",re1,re2,re3,re4);

BOOL re5 = [(id)[NSObject alloc] isKindOfClass:[NSObject class]];      
BOOL re6 = [(id)[NSObject alloc] isMemberOfClass:[NSObject class]];    
BOOL re7 = [(id)[LGPerson alloc] isKindOfClass:[LGPerson class]];     
BOOL re8 = [(id)[LGPerson alloc] isMemberOfClass:[LGPerson class]];   
NSLog(@" re5 :%hhd\n re6 :%hhd\n re7 :%hhd\n re8 :%hhd\n",re5,re6,re7,re8);
Copy the code
  • A: 1011 1111

  • B: 1100 1011

  • C: 1000 1111

  • D: 1101 1111

    1. (x + 7) & ~7This algorithm is a few bytes aligned score worth 5 points
  • A: 7

  • B: 8

  • C: 14

  • D: 16

    1. Determine the size of the following data structures on a 5-point scale
union kc_t {
    uintptr_t bits;
    struct {
        int a;
        char b;
    };
}
Copy the code
  • A: 8

  • B: 12

  • C: 13

  • D: 16

    1. The metaclass isa points to and the root metaclass’s parent is worth 5 points
  • A: Self, root metaclass

  • B: Self, NSObject

  • C: root metaclass, root metaclass

  • D: root metaclass, NSObject

    1. When looking for the method cache, it is out of order. Why? How do hash conflicts get resolved out of 5 points
  • A: Hash function cause, not solved

  • B: Hash function reason, hash again

  • C: He deposited his I also phuket island, again hash

  • D: His mess is his mess, breeze over the hills, not solved

    1. The flow of messages is worth five points
  • A: Quick lookup from the cache first

  • B: Slow recursive lookup of methodList (own and parent until parent is nil)

  • C: Dynamic method resolution

  • D: message forwarding process

    1. Why should class method dynamic method resolution be implemented laterresolveInstanceMethodScore five points
  • A: Class methods have metaclasses (in the form of object methods) whose superclass is ultimately NSObject so we can prevent object methods from being implemented in NSObject with resolveInstanceMethod!

  • B: Because at the bottom of oc, object methods still exist

  • C: Class methods exist metaclasses exist in the form of object methods.

  • D: Salty radish, light worry! Don’t worry about what Apple wrote

(5 points)

    1. We can’t tell if an object has an associated object just by looking at the address of our object. 5 points
    1. Int c [4] = {1, 2, 3, 4}; int *d = c; c[2] = *(d+2)Score five points
    1. @interface LGPerson : NSObject{ UIButton *btn }Among thembtnThe value of an instance variable is 5 points
    1. NSObjectExcept metaclass’s parent class = metaclass’s value 5 points
    1. The address of the object is the first address of the memory element
    1. A class is also an object worth 5 points

3. Simple questions (10 points for each question)

Please treat it as an interview and take it seriously. I hope you will be patient and avoid impetuous.

  • How to restore the upper OC code to C++ code score value 10 points

  • How to open the assembly to view the process, what are the benefits? Score 10 points

  • X /4gx and p/x and p *$0 = 10

  • Where do class methods exist? Why do we do this? Score 10 points

  • Method of binary search process in the slow search process, please use pseudocode to achieve the score value of 10 points

  • ISA_MASK = 0x00007FFFFFFff8ULL what is the meaning of this ISA_MASK algorithm? Score 10 points

  • Why are there rW, ro and RWE in the class structure? Score 10 points

  • When is cache capacity expanded and why? Score 10 points

  • Why is objc_msgSend written in an assembly? How does objc_msgSend recursively find imp? Score 10 points

  • 26. Why can a class call a method on an NSObject whose class method is not implemented

Four, expand full marks (20 points

  1. Submit a masterclass and your best blog post is worth 20 points

Five, the summary

The questions of the exam are biased to the bottom, which is also more suitable for the current iOS interview market! The content is deep and shallow, but also can continue to dig holes (👀)

Disclaiming: The content is intended to facilitate learning and is not intended to add volume to the industry. I hope you don’t use these questions as interview material to embarrass job seekers. The answer can be directly wechat me: KC_Cooci