अभी पंजीकरण करें

लॉग इन करें

पासवर्ड खो गया

आपका पासवर्ड खो गया है? कृपया अपना पूरा ईमेल दर्ज करें. आपको एक लिंक प्राप्त होगा और आप ईमेल के माध्यम से एक नया पासवर्ड बनाएंगे.

पोस्ट जोड़ें

पोस्ट जोड़ने के लिए आपको लॉगिन करना होगा .

प्रश्न जोड़ें

प्रश्न पूछने के लिए आपको लॉगिन करना होगा.

लॉग इन करें

अभी पंजीकरण करें

स्कॉलरसार्क.कॉम में आपका स्वागत है! आपका पंजीकरण आपको इस प्लेटफॉर्म की अधिक सुविधाओं का उपयोग करने की अनुमति देगा. आप सवाल पूछ सकते हैं, योगदान दें या उत्तर दें, अन्य उपयोगकर्ताओं के प्रोफ़ाइल देखें और बहुत कुछ. अभी पंजीकरण करें!

LinkedIn skill assessment answers and questions — Swift

तीव्र has emerged as a powerful and intuitive programming language for developing iOS, मैक ओएस, and watchOS applications, offering developers a modern and efficient platform for building innovative software. इस व्यापक मार्गदर्शिका में, हम इसकी एक श्रृंखला प्रस्तुत करते हुए रोमांचित हैं skill assessment questions तथा जवाब के लिए विशेष रूप से तैयार किया गया तीव्र उपयोगकर्ताओं.

Whether you’re a seasoned developer looking to expand your capabilities or a beginner aiming to understand the basics of this powerful language, this resource is designed to help you become proficient in तीव्र और इसके अनुप्रयोग. Join us as we explore the core concepts of तीव्र प्रोग्रामिंग, including optionals, closures, protocols, और अधिक, empowering you to leverage the full potential of this essential tool for your iOS and macOS projects.

Q1. What is this code an example of?

let val = (Double)6
  • A syntax issue
  • Typecasting
  • Assignment
  • Initialization

संदर्भ: The Swift Programming Language: Language Guide: मूल बातें: Constants and Variables

Q2. What is the error in this code?

let x = 5
guard x == 5 { return }
  • NS guard is missing the else
  • Nothing is wrong
  • NS guard is missing a then
  • The comparison is wrong

संदर्भ: The Swift Programming Language: Language Guide: बहाव को काबू करें: Early Exit

Q3. What is the raw/underlying type of this enum?

enum Direction {
  case north, south, east, west
}
  • There is none
  • String
  • Any
  • Int

संदर्भ: The Swift Programming Language: Language Guide: Enumerations: Raw Values

Q4. Why is dispatchGroup used in certain situations?

  • It allows multiple synchronous or asynchronous operations to run on different queues.
  • It allows track and control execution of multiple operations together.
  • It allows operations to wait for each other as desired.
  • All of these answers.

संदर्भ: Apple Developer: प्रलेखन: Dispatch: Dispatch Group

Q5. What is this code an example of?

let val = 5
print("value is: \(val)")
  • String interpolation
  • String compilation
  • Method chaining
  • String concatenation

संदर्भ: The Swift Programming Language: Language Guide: Strings and Characters: String Interpolation

Q6. What are the contents of vals after this code is executed?

var vals = [10, 2]
vals.sort { (s1, s2) -> Bool in
  s1 > s2
}
  • [10, 2]
  • [2, 10]
  • nil
  • This code contains an error

संदर्भ: Apple Developer: Documentations: तीव्र: सरणी: क्रम से लगाना()

क्यू 7. What does this code print?

typealias Thing = [String: Any]
var stuff: Thing
print(type(of: stuff))
  • Dictionary<String, Any>
  • Dictionary
  • Error
  • Thing

संदर्भ: The Swift Programming Language: Language Reference: प्रकार: Type Identifier

क्यू 8. What is the value of y?

let x = ["1", "2"].dropFirst()
let y = x[0]
  • This code contains an error
  • 1
  • 2
  • nil

explanation
dropFirst() से Swift.Collection.Array returns a type of ArraySlice<Element>
as in the documentation pages:
@inlinable public func dropFirst(_ k: Int = 1) -> ArraySlice<Element>

The ArraySlice type makes it fast and efficient for you to perform operations on sections of a larger array. Instead of copying over the elements of a slice to new storage, an ArraySlice instance presents a view onto the storage of a larger array. And because ArraySlice presents the same interface as Array, you can generally perform the same operations on a slice as you could on the original array.

Slices Maintain Indices
Unlike Array and ContiguousArray, the starting index for an ArraySlice instance isn’t always zero. Slices maintain the same indices of the larger array for the same elements, so the starting index of a slice depends on how it was created, letting you perform index-based operations on either a full array or a slice.
The above code returns a slice of value ["2"] but the index did not change. let y = x[1] would give the expected result.
To safely reference the starting and ending indices of a slice, always use the startIndex and endIndex properties instead of specific values.
संदर्भ

प्रश्न 9. What is the value of test in this code?

var test = 1 == 1
  • true
  • YES
  • 1
  • This code contains an error

संदर्भ: The Swift Programming Language: Language Guide: Basic Operators: Comparison Operators

प्र10. What is the value of y?

var x: Int?
let y = x ?? 5
  • 5
  • 0
  • nil
  • This code contains an error

संदर्भ: The Swift Programming Language: Language Guide: Basic Operators: Nil-Coalescing Operators

प्रश्न 11. What is the type of this function?

func add(a: Int, b: Int) -> Int { return a+b }
  • Int
  • (Int, Int) -> Int
  • Int<Optional>
  • Functions don’t have types.

संदर्भ: The Swift Programming Language: Language Guide: कार्यों: Function Types

प्र12. What is the correct way to call this function?

func myFunc(_ a: Int, b: Int) -> Int {
  return a + b
}
  • myFunc(5, b: 6)
  • myFunc(5, 6)
  • myFunc(a: 5, b: 6)
  • myFunc(a, b)

संदर्भ: The Swift Programming Language: Language Guide: कार्यों: Function Argument Labels and Parameter Names

प्रश्न 13. The Codable protocol is _?

  • A combination of Encodable तथा Decodable
  • Not a true protocol
  • Required of all classes
  • Automatically included in all classes

संदर्भ:

प्र14. What is the type of value1 in this code?

let value1 = "\("test".count)"
  • String
  • Int
  • null
  • test.count

संदर्भ: The Swift Programming Language: Language Guide: Strings and Characters: String Interpolation

प्रश्न 15. When a function takes a closure as a parameter, when do you want to mark is as escaping?

  • When it’s executed after the function returns
  • When it’s scope is undefined
  • When it’s lazy loaded
  • All of these answers

संदर्भ: The Swift Programming Language: Language Guide: Closures: Escaping Closures

प्र16. What’s wrong with this code?

class Person {
  var name: String
  var address: String
}
  • Person has no initializers.
  • Person has no base class.
  • var name is not formatted correctly.
  • address is a keyword.

संदर्भ: The Swift Programming Language: Language Guide: Initialization: Class Inheritance and Initialization

प्रश्न 17. What is the value of names after this code is executed?

let names = ["Bear", "Joe", "Clark"]
names.map { (s) -> String in
  return s.uppercased()
}
  • ["BEAR", "JOE", "CLARK"]
  • ["B", "J", "C"]
  • ["Bear", "Joe", "Clark"]
  • This code contains an error.

प्रश्न 18. What describes this line of code?

let val = 5
  • A constant named val of type Int
  • A variable named val of type item
  • A constant named val of type Number
  • A variable named val of type Int

संदर्भ: The Swift Programming Language: Language Guide: मूल बातें: Type Safety and Type Inference

क्यू19. What is the error in this code?

extension String {
  var firstLetter: Character = "c" {
    didSet {
      print("new value")
    }
  }
}
  • Extensions can’t add properties.
  • Nothing is wrong with it.
  • didSet takes a parameter.
  • c is not a character.

संदर्भ: The Swift Programming Language: Language Guide: Extensions: Computed Properties

प्र20. didSet and willSet are examples of _?

  • Property observers
  • Key properties
  • All of these answers
  • newOld value calls

संदर्भ: The Swift Programming Language: Language Guide: गुण

प्र21. What is wrong with this code?

self.callback = {
  self.attempts += 1
  self.downloadFailed()
}
  • Use of self inside the closure causes retain cycle.
  • You cannot assign a value to a closure in this manner.
  • You need to define the type of closure explicitly.
  • There is nothing wrong with this code.

संदर्भ: The Swift Programming Language: Language Guide: Automatic Reference Counting: Strong Reference Cycles for Closures

प्र22. How many values does vals have after this code is executed?

var vals = Set<String> = ["4", "5", "6"]
vals.insert("5")
  • Three
  • चार
  • Eight
  • This code contains an error.

संदर्भ: The Swift Programming Language: Language Guide: Collection Types: सेट

प्र23. How can you avoid a strong reference cycle in a closure?

  • Use a capture list to set class instances of weak या unowned.
  • You can’t, there will always be a danger of strong reference cycles inside a closure.
  • Initialize the closure as read-only.
  • Declare the closure variable as lazy.

संदर्भ: The Swift Programming Language: Language Guide: Automatic Reference Counting

प्र24. What is wrong with this code?

if let s = String.init("some string") {
  print(s)
}
  • इस String initializer does not return an optional.
  • String does not have an initializer that can take a String.
  • = is not a comparison.
  • Nothing is wrong with this code.

संदर्भ: The Swift Programming Language: Language Guide: मूल बातें: Optionals

प्रश्न25. Which code snippet correctly creates a typealias closure?

  • typealias CustomClosure = () -> ()
  • typealias CustomClosure { () -> () }
  • typealias CustomClosure -> () -> ()
  • typealias CustomClosure -> () {}

संदर्भ: The Swift Programming Language: Language Reference: Declarations: Type Alias Declaration

प्र26. How do you reference class members from within a class?

  • self
  • instance
  • class
  • this

संदर्भ: The Swift Programming Language: Language Guide: तरीकों: Instance Methods

प्र27. All value types in Swift are _ under the hood?

  • Structs
  • कक्षाओं
  • Optionals
  • Generics

संदर्भ: The Swift Programming Language: Language Guide: Structures and Classes

प्रश्न 28. What is the correct way to add a value to this array?

var strings = [1, 2, 3]
  • All of these answers
  • strings.append(4)
  • strings.insert(5, at: 1)
  • strings += [5]

संदर्भ: The Swift Programming Language: Language Guide: Collection Types: Arrays

प्र29. How many times will this loop be executed?

for i in 0...100 {
  print(i)
}
  • 0
  • 101
  • 99
  • 100

संदर्भ:

क्यू30. What can AnyObject represent?

  • An instance of any class
  • An instance of function type
  • All of these answers
  • An instance of an optional type

संदर्भ: The Swift Programming Language: Language Guide: Type Casting: Type Casting for Any and AnyObject

प्रश्न31. What is the value of t after this code is executed?

let names = ["Larry", "Sven", "Bear"]
let t = names.enumerated().first().offset
  • This code does not compile. / This code is invalid.
  • 0
  • 1
  • Larry

संदर्भ:

प्र32. What is the value of test after this code executes?

let vt = (name: "ABC", val: 5)
let test = vt.0
  • ABC
  • 0
  • 5
  • name

संदर्भ:

प्रश्न 33. What is the base class in this code?

class LSN: MMM {
}
  • MMM
  • LSN
  • There is no base class.
  • This code is invalid.

संदर्भ: The Swift Programming Language: Language Guide: विरासत: Subclassing

प्रश्न34. What does this code print to the console?

var userLocation: String = "Home" {
  willSet(newValue) {
    print("About to set userLocation to \(newValue)...")
  }

  didSet {
    if userLocation != oldValue {
      print("userLocation updated with new value!")
    } else {
      print("userLocation already set to that value...")
    }
  }
}

userLocation = "Work"
  • About to set userLocation to Work... userLocation updated with new value!
  • About to set userLocation to Work... userLocation already set to that value...
  • About to set userLocation to Home... userLocation updated to new value!
  • Error

संदर्भ: The Swift Programming Language: Language Guide: गुण: Property Observers

क्यू35. What must a convenience initializer call?

  • A base class convenience initializer
  • Either a designated or another convenience initializer
  • A designated initializer
  • None of these answers

संदर्भ: The Swift Programming Language: Language Guide: Initialization: Class Inheritance and Initialization

प्र36. Which object allows you access to specify that a block of code runs in a background thread?

  • DispatchQueue.visible
  • DispatchQueue.global
  • errorExample need to be labeled as throws.
  • DispatchQueue.background

संदर्भ: Apple Developer: प्रलेखन: Dispatch: DispatchQueue

प्रश्न37. What is the inferred type of x?

let x = ["a", "b", "c"]
  • String[]
  • Array<String>
  • Set<String>
  • Array<Character>

संदर्भ: The Swift Programming Language: Language Guide: Collection Types: Arrays

प्रश्न 38. What is the value of oThings after this code is executed?

let nThings: [Any] = [1, "2", "three"]
let oThings = nThings.reduce("") { "\($0)\($1)" }
  • 11212तीन
  • 115
  • 12तीन
  • Nothing, this code is invalid.

संदर्भ: Apple Developer: प्रलेखन: तीव्र: सरणी: reduce(_:_:)

प्र39. How would you call a function that throws errors and also returns a value?

  • !try
  • try?
  • try!
  • ?try

संदर्भ: The Swift Programming Language: Language Guide: Error Handling: Handling Errors

क्यू40. What is wrong with this code?

protocol TUI {
  func add(x1: Int, x2: Int) -> Int {
    return x1 + x2
  }
}
  • Protocol functions cannot have return types.
  • Protocol functions cannot have implementations.
  • Nothing is wrong with it.
  • add is a reserved keyword.

संदर्भ:

प्र41. In this code, what are wheels तथा doors examples of?

class Car {
  var wheels: Int = 4
  let doors = 4
}
  • Class members
  • This code is invalid
  • Class fields
  • Class properties

संदर्भ:

प्र42. How do you designated a failable initializer?

  • You cannot
  • deinit
  • init?
  • init

संदर्भ:

प्रश्न 43. What is printed when this code is executed?

let dbl = Double.init("5a")
print(dbl ?? ".asString()")
  • five
  • 5a
  • .asString()
  • 5

संदर्भ:

प्रश्न 44. In the function below, what are this तथा toThat examples of?

func add(this x: Int, toThat y: Int) { }
  • None of these answers
  • Local terms
  • Argument labels
  • Parameters names

संदर्भ: The Swift Programming Language: Language Guide: कार्यों

क्यू45. What is wrong with this code?

for (key, value) in [1: "one", 2: "two"] {
  print(key, value)
}
  • The interaction source is invalid
  • The interaction variable is invalid
  • There is nothing wrong with this code
  • The comma in the print is misplaced

संदर्भ: The Swift Programming Language: Language Guide: बहाव को काबू करें: For-In Loops

प्र46. Which of these choices is associated with unit testing?

  • XCTest
  • All of these answers
  • @testable
  • XCTAssert

संदर्भ:

प्रश्न 47. नीचे दिए गए कोड में, what is width an example of?

class Square {
  var height: Int = 0
  var width: Int {
    return height
  }
}
  • This code contains error
  • A closure
  • A computed property
  • Lazy loading

संदर्भ:

प्रश्न 48. What data type is this an example of?

let vals = ("val", 1)
  • एक शब्दकोष
  • A tuple
  • An optional
  • This code contains error

संदर्भ:

प्र49. What is wrong with this code?

var x = 5
x = 10.0
  • You cannot assign a Double to a variable of type Int
  • x is undefined
  • x is a constant
  • x has no type

संदर्भ: The Swift Programming Language: Language Guide: मूल बातें

क्यू50. What will this code print to the console?

var items = ["a": 1, "b": 2, "c": "test"] as [String: Any]
items["c"] = nil
print(items["c"] as Any)
  • Any
  • परीक्षण
  • 1,2,3
  • nil

संदर्भ:

प्रश्न51. What is wrong with this code?

let val = 5.0 + 10
  • There is nothing wrong with this code
  • val is a constant and cannot be changed
  • 5.0 तथा 10 are different types
  • There is no semicolon

संदर्भ: The Swift Programming Language: Language Guide: मूल बातें: Type Safety and Type Inference

प्रश्न52. How many parameters does the initializer for Test have?

struct Test {
  var score: Int
  var date: Date
}
  • Zero
  • This code contains an error
  • Two
  • Structs do not have initializers

संदर्भ: The Swift Programming Language: Language Guide: Initialization

प्रश्न53. What prints to the console when executing this code?

let x = try? String.init("test")
print(x)
  • nil
  • Nothingthis code contains an error
  • ऐच्छिक(“परीक्षण”)
  • परीक्षण

संदर्भ:

प्रश्न54. How can you sort this array?

var vals = [1, 2, 3]
  • vals.sort { $0 < $1 }
  • vals.sort { (s1, s2) in s1 < s2 }
  • vals.sort(by: <)
  • All of these answers

संदर्भ: Apple Developer: प्रलेखन: तीव्र: सरणी: क्रम से लगाना()

प्रश्न55. DispatchQueue.main.async takes a block that will be

  • Not executed
  • Executed in the main queue
  • None of these answers
  • Executed on the background thread

संदर्भ: Apple Developer: प्रलेखन: Dispatch: DispatchQueue: async(समूह:qos:flags:अमल में लाना:)

प्रश्न56. When is deinit called?

  • When a class instance needs memory
  • All of these answers
  • When the executable code is finished
  • When a class instance is being removed from memory

संदर्भ: The Swift Programming Language: Language Guide: Deinitialization

प्रश्न57. How do you declare an optional String?

  • String?
  • Optional[String]
  • [String]?
  • ?String

संदर्भ: The Swift Programming Language: Language Guide: मूल बातें: Optionals

प्र 58. How many times this code will be executed? / How many times will this loop be performed?

for i in ["0", "1"] {
  print(i)
}
  • एक
  • Two
  • Three
  • This code does not compile

संदर्भ: The Swift Programming Language: Language Guide: बहाव को काबू करें: For-In Loops

प्रश्न59. What does this code print?

let names = ["Bear", "Tony", "Svante"]
print(names[1] + "Bear")
  • 1Bear
  • BearBear
  • TonyBear
  • Nothing, this code is invalid

संदर्भ:

क्यू 60. What is true of this code?

let name: String?
  • name can hold only a string value.
  • name can hold either a string or nil value.
  • Optional values cannot be let स्थिरांक.
  • Only non-empty string variables can be stored in name.

संदर्भ: The Swift Programming Language: Language Guide: मूल बातें: Optionals

प्रश्न 61. What is the value of val after this code is executed?

let i = 5
let val = i * 6.0
  • This code is invalid.
  • 6
  • 30
  • 0

संदर्भ: The Swift Programming Language: Language Guide: मूल बातें: Type Safety and Type Inference

प्रश्न 62. What does this code print?

enum Positions: Int {
  case first, second, third, other
}

print (Positions.other.rawValue)
  • 3
  • 0
  • अन्य
  • nil

संदर्भ: The Swift Programming Language: Language Guide: मूल बातें: Raw Values

प्रश्न 63. What is printed to the console when this code is executed?

"t".forEach { (char) in
  print(char)
}
  • nil
  • Nothing, since the code contains an error
  • टी
  • zero

संदर्भ:

प्रश्न 64. What prints when this code is executed?

let s1 = ["1", "2", "3"]
  .filter { $0 > "0" }
  .sorted { $0 > $1 }
print(s1)
  • []
  • [“3”, “2”, “1”]
  • [321]
  • [“1”, “2”, “3”]

संदर्भ:

प्रश्न 65. What enumeration feature allows them to store case-specific data?

  • Associated values
  • Integral values
  • Raw values
  • Custom values

संदर्भ: The Swift Programming Language: Language Guide: Enumerations: Associated Values

प्रश्न 66. नीचे दिए गए कोड में, AOM must be a(एन)?

class AmP: MMM, AOM { }
  • Class
  • Protocol
  • Enumeration
  • Struct

संदर्भ:

प्रश्न 67. What is the value of numbers in the code below?

let numbers = [1, 2, 3, 4, 5, 6].filter { $0 % 2 == 0 }
  • [1, 3, 5]
  • []
  • [2, 4, 6]
  • nil

संदर्भ: Apple Developer: प्रलेखन: तीव्र: Swift Standard Library: Collections: Sequence and Collection Protocols: अनुक्रम: फ़िल्टर()

प्रश्न 68. What is the type of vals in this code?

let vals = ["a", 1, "Hi"]
  • सरणी(char)
  • [Any]
  • सरणी
  • [Generic]

संदर्भ: The Swift Programming Language: Language Guide: Type Casting

प्रश्न 69. How can you extract val to x in tuple vt

let vt = (name: "ABC", val: 5)
  • let x = vt.1
  • All of these answers
  • let x = vt.val
  • होने देना (_, एक्स) = vt

संदर्भ: The Swift Programming Language: Language Guide: मूल बातें: टुपल्स

क्यू 70. What is the type of x?

let x = try? String.init(from: decoder)
  • String
  • String?
  • String!
  • try?

संदर्भ: The Swift Programming Language: Language Guide: Error Handling: Handling Errors

प्र71. How many times is this loop executed?

let loopx = 5
repeat {
  print (loopx)
} while loopx < 6
  • Six
  • Zero
  • Five
  • Infinite

संदर्भ: The Swift Programming Language: Language Guide: बहाव को काबू करें: While Loops

प्र72. How many values does vals have after this code is executed?

var vals: Set<String> = ["4", "5", "6"]
vals.insert("5")
  • This code contains an error.
  • Eight
  • Three
  • चार

संदर्भ: The Swift Programming Language: Language Guide: Collection Types: सेट

प्रश्न 73. What is the base class in this code ?

class LSN: MMM{ }

  • MMM
  • LSN
  • There is no base class.
  • This code is invalid.

के बारे में हेलेन बस्सी

नमस्ते, I'm Helena, एक ब्लॉग लेखक जिसे शिक्षा क्षेत्र में ज्ञानवर्धक सामग्री पोस्ट करने का शौक है. मेरा मानना ​​है कि शिक्षा व्यक्तिगत और सामाजिक विकास की कुंजी है, और मैं अपने ज्ञान और अनुभव को सभी उम्र और पृष्ठभूमि के शिक्षार्थियों के साथ साझा करना चाहता हूं. मेरे ब्लॉग पर, आपको सीखने की रणनीतियों जैसे विषयों पर लेख मिलेंगे, ऑनलाइन शिक्षा, व्यवसायिक नीति, और अधिक. मैं अपने पाठकों की प्रतिक्रिया और सुझावों का भी स्वागत करता हूं, इसलिए बेझिझक एक टिप्पणी छोड़ें या किसी भी समय मुझसे संपर्क करें. मुझे आशा है कि आपको मेरा ब्लॉग पढ़ने में आनंद आएगा और यह उपयोगी और प्रेरणादायक लगेगा.

उत्तर छोड़ दें