LinkedIn skill assessment answers and questions — Objective-C
“Objective-C is a powerful object-oriented programming language that forms the foundation of iOS app development. En esta guía completa, we’re excited to present a series of preguntas de evaluación de habilidades y respuestas diseñado específicamente para Objective-C.
Si es un desarrollador experimentado que busca ampliar sus capacidades o un principiante que desea comprender los conceptos básicos de este poderoso lenguaje., this resource is designed to help you become a master of Objective-C y sus aplicaciones. Join us as we explore the fundamentals of Objective-C, memory management, delegation patterns, and other critical aspects of working with this cutting-edge language.”
Q1. What is the value of s?
NSMutableString *s = [NSMutableString stringWithString: @"123"];
[s appendString: @"456"];
- 123456
- 123
- 123
- 456
- Este código contiene un error..
What’s the value of i after these statements?
Q2.NSString *str = nil;
NSInteger i = str.integerValue;
- nulo
- 0 (technically
nil
== 0 but i will have a literal value of0
and not thevoid*
value ofnil
) - -1
- This code crashes.
What value is in str after this line in executed?
Tercer trimestre.NSString str = "test" + " " + "more";
- Este código contiene un error.
- prueba
- nulo
- test more
What is the output of the code given below?
Cuarto trimestre. NSPredicate *p2 = [NSPredicate predicateWithBlock:^BOOL(NSString* evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
return evaluatedObject.intValue % 2 == 0;
}];
NSArray *vals = @[@"1", @"2", @"3"];
NSArray *n2 = [vals filteredArrayUsingPredicate:p2];
NSLog(@"%@", n2.firstObject);
- 2
- 1,2,3
- 1,2
- Nada, since this code contains an error.
Property defaults include _?
Q5.- atomic/strong
- atomic/weak
- nonatomic/weak
- nonatomic/strong
What is the key difference between NSDictionary and NSMutableDictionary?
Q6.- NSMutableDictionary’s values can change
- NSMutableDictionary has not initializers.
- NSDictionary can’t be copied.
- NSDictionary’s values can change.
What is foo?
Q7.-(float)foo;
- A function with a return type of float.
- Este código contiene un error..
- A variable declaration of type float.
- A property of type float.
What can you glean from this line?
Q8.#import "NSString+NameHelper.h"
- NameHelper is a category of NSString.
- NameHelper is a subclass of NSString.
- NSString implements the NameHelper protocol.
- NSString has a helper class.
Q9. ¿Qué hay de malo en este código??
float x = 5.;
- No hay nada malo con este código.
- Declarations do not need semicolons.
- x=5 is an invalid float.
- Variables can’t be declared and initialized in the same state.
How many times with this loop be executed?
Q10.for (int x=0; x<100; x++) {
x = x + 1;
}
- 50
- 99
- 100
- Este código contiene un error..
tecnicos. ¿De qué es este código un ejemplo??
[self addObserver: self forKeyPath: @"val" options:0 context: nil];
- Key-Value Observing
- Class Value Observing
- Key-Data Observing
- KeyPath Observing
What does ARC stand for?
Q12.- Conteo automático de referencias
- Automatic Retain Checking
- Async Retain Cycles
- Automatic Release Code
What is printed for this code?
P13.int val = 0;
val = 1.5;
printf("%d", val);
- 1
- 2
- 0
- Este código contiene un error..
What best describes class inheritance in Objective-C?
Q14.- single inheritance but multiple protocol implementation
- Objective-C doesn’t support inheritance
- dual class inheritance
- unlimited class inheritance and protocol adherence
How many keys does this NSDictionary have after this code is executed?
P15.NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys: @"b", @"e", @"a", @"r", nil];
- 2
- 4
- 5
- Este código contiene un error..
Q16. ¿Cuál es el error en este código??
NSMutableDictionary *dict1 = [NSMutableDictionary dictionaryWithCapacity:5];
[dict1 setValue:@"key" forKey:@"value"];
- The key and value items are mixed
- No hay nada malo en ello
- You can’t set the capacity of a dictionary
- NSMutableDictionary doesn’t have a :setValue:forKey function.
What is printed from this code?
P17.NSData *data = [@"print" dataUsingEncoding:NSASCIIStringEncoding];
NSLog(@"%@", [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]);
- imprimir
- Este código no es válido
- Nothing is printed from this code.
- nulo
What is different about this function?
P18.+(void)doSomething;
- It is static
- It is abstract.
- It is inline.
- Este código contiene un error..
Structs can have _?
Q19.- mejoraremos nuestro archivo MAKE y la plantilla de archivo MAKE creados en el Proyecto n. ° 1 aplicando patrones
- initializers
- campos
- todas estas respuestas
P20. Qué está mal con este código?
@interface MyClass : NSObject
@property (strong, nonatomic, readonly) NSString *name;
@end
- No hay nada malo con este código.
- There is not read-only directive.
- MyClass doesn’t implement NSObject.
- Properties are declared in the implementation.
What is an enums base type for the code below?
P21.typedef enum { Foo1, Foo2} Foo;
- There is no base type.
- NSObject
- En t
- NSNumber
If you want to store a small amount of information (por ejemplo, user settings), whats the best, built-in way to go?
P22.- UserDefaults
- plist file
- CoreData
- TextFile
What are categories used for?
Q23.- to extend other classes
- to manage access control
- to coordinate objects
- to group classes
What is this Objective-C code checking?
P24.if ([keyPath isInstanceOf:[NSString class]]) {
}
- Este código contiene un error.
- if keyPath is an instance of NSString
- if keyPath’s baseclass is the same as NSString’s baseclass
- if keyPath implements the same methods as NSString
What is this a declaration of?
P25.int(^foo)(int);
- an Extension
- a Generic
- a block of code
- an abstract class
For observing changes to a property, which of these two statements cause the related method to be called and why?
Q26.1. _val = 1;
2. self.val= 100;
- Declaración 2, since it calls the auto-created setter on the property.
- Declaración 1, since it uses the property directly.
- Declaración 2, since it specifies the class instance to use.
- Declaración 1, since it calls the auto-created setter on the property.
Q27. Qué está mal con este código?
float x = 2.0;
int(^foo)(int) = ^(int n1) {
return (int)(n1*x);
};
foo(5);
- Ints and floats can’t be multiplied.
- The parameter isn’t declared correctly.
- x is not in the right scope.
- No hay nada malo con este código.
What’s the difference between an array and a set?
P28.- Arrays are ordered, non-unique values.
- Arrays are stored sorted.
- Sets are ordered, unique values.
- Sets can contain nils.
Dot notation can be used for _?
Q29.- nada, as they’re never used in Objective-C
- function calls only
- property getter/setter
- parameter delimiters
What is the value of newVals after this code is executed?
Q30.NSArray *vals = @[@"1", @"2", @"3"];
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF.intValue > 1"];
NSArray *newVals = [vals filteredArrayUsingPredicate:pred];
- 2,3
- nulo
- Este código contiene un error.
- 2,”3″
How would this function be called?
P31.-(int)foo:(int)a b:(int)c;
- self.foo(5, si:10);
- Este código contiene un error..
- [self foo:5:10:20];
- [self foo:5 si:10];
What is the type of the error return value stored in json?
Q32.NSError *error;
NSData *data;
id json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error];
- NSString
- NSArray
- Variables y métodos estáticos
- NSDictionary
What is significant about this function declaration?
para celebrar el éxito y resaltar las áreas de oportunidad.-(void)testFunc:(NSString**)str;
- The parameter is passed by value and can not be changed
- ** is not allowed on a parameter
- The parameter may be nil
- The parameter is passed by reference and may be changed
What is printed from this code execution?
P34.typedef enum {
thing1,
thing2,
thing3
} Thing;
-(void) enumStuff {
NSLog(@"%d", thing2);
}
- 0
- 1
- thing2
- This code does not print anything
You are worried about threaded access to a property and possible collision in writing. What directive should you use on the property?
entonces solo habrá falla si el defecto ocurre en cada capa y estas están todas alineadas al mismo tiempo.- non-atomic
- fuerte
- weak
- atomic
What is wrong with this line of code?
Q36.int temp = 1==1;
-
temp
es una palabra clave. - 1==1 is invalid.
- 1==1 evaluates to a Boolean.
- No hay nada malo en ello.
What is special about the code within this block?
P37.dispatch_async(dispatch_get_main_queue(), ^{
// code
});
- It executes on the main queue.
- It is the last code to run before the app goes inactive.
- It executes on a background thread.
- It is queued to execute in the background.
How many items are in set1 after this code executes?
P38.NSMutableSet *set1 = [NSMutableSet setWithObjects: @1,@2, @3, @4, @5, nil];
[set1 add0bject:@3];
- cero
- seis
- uno
- cinco
P39. Qué está mal con este código?
NSDictionary *d1 = @[@"v1", @4, @"v2", @5.6, @"v3"];
NSlog(@"d1: %@", d1);
- NSDictionary cannot be printed this way.
- The last key is missing a value.
- Dictionaries cannot have mixed types as values.
- d1 is assigned an NSArray of values.
What is the initial value of the property val
?
Q40. @property (nonatomic, readonly) int val;
- 8
- nulo
- -1
- indefinido
Which thread should UI updates be processed on to avoid crashes and application lag?
P41.- interfaz de usuario
- dispatch
- fondo
- main
What is the value of val after this code is executed?
P42.NSString *val = @"1.23";
BOOL tf = val.boolValue;
- Este código no es válido
- SÍ
- NO
- 1
what does ThatOne refer to?
Q43. en este codigo,@interface TestClass : ThisOne <ThatOne>
- the parent class of TestClass
- the name of the category being created for ThisOne
- a protocoL impLemented by ThisOne
- a helper file’s name
What is the value of result after this code is executed?
Q44.NSString *result = [Ftest"
stringByTrimmingCharactersInSet.NSCharacterSet.alphanumericCharacterSet];
- “”
- “es”
- “prueba”
- ninguna de estas respuestas
When will self receive the notification based on this code?
P45.MyClass .classObj = [[MyClass allot] init];
[class0bj add0bserver:self forKeyPath:@"name"
options:NSKeyValueObservingOptionNew context:NULL];
- ninguna de estas respuestas
- class0bj will recieve the notification, not self.
- when class0bj is set to “nombre”
- when the name property in the class0bj instance changes
Q46. Qué está mal con este código?
[*"true" boolValue];
- String literal are not created with*.
- NSString doesn’t have a boolValue function.
- “cierto” has no meaning.
- No hay nada malo con este código.
How many times does this loop execute?
P47.int loopVal = 0;
for (int i=0; i>loopVal; i--){
i--;
}
- an infinite number of times
- Este código no es válido.
- cero
- uno
What will this code print?
Q48.NSLog(@"%lu", @"test".length);
- “prueba”
- Nada, este código no es válido.
- 4
- 0
What is the value of numVtoInt after this code is executed?
Q49.NSNumber *numV = [NSNumber numberWithFloat:6.7];
int numVtoInt = numV.intValue;
- 6
- 0
- 6.7
- 7
Q50. ¿Qué imprime este código??
NSString *val = @"1.23";
NSLog(@"%.04f", val.floatValue);
- 1.2300
- .04
- Este código no es válido
- 1
What is the maximum possible value of r1 in this code?
P51.int r1 = arc4random() % 10;
- 0
- 9
- 1
- 10
Deja una respuesta
Debes iniciar sesión o registro para agregar un nuevo comentario .