Thursday, December 1, 2016

Objective Questions in >= Swift2.2 @iPhone - Set E

Q.41: What will be the output
var temp = 30
if temp >= 34 {
    print("It's Cold")
}
else
{
print("It's Normal")
}
A.      Compile Time Error
B.      It’s Cold
C.      It’s Normal
D.      None

Q.42: What will be the output
let temp = 90
if temp <= 32 {
    print("It's very cold.")
} else if temp >= 86 {
    print("It's really warm.")
} else {
    print("It's Normal")
}
A.      Compile Time Error
B.      It’s very cold
C.      It’s really warm
D.      It’s Normal

Q.43: What will be the output
let char: Character = "B"
switch char {
case "A":
    print("The first letter of the alphabet")
case "B":
    print("The second letter of the alphabet")
case "Z":
    print("The last letter of the alphabet")
default:
    print("Some other character")
}
A.      The first letter of the alphabet
B.      The second letter of the alphabet
C.      The last letter of the alphabet
D.      Some other character

Q.44: What will be the output
let char: Character = "b"
switch char
{
case "b", "B":
    print("The letter is B")
default:
    print("Not B")
}
A.      Compile Time Error
B.      The letter is B
C.      Not B
D.      None of the above

Q.45: Which is not a proper function in Swift
                A. func humtum( name : String ) -> String {   
                      some code      …… 
                      return  “Hello”}
                B. func humtum( name : String ) {   
                      some code      …… 
                      }
                C. func humtum() -> String {   
                      some code      …… 
                      return  “Hello”
      }
                D. humtum( name : String ) -> String {   
                      some code      …… 
                      return  “Hello”}

Q. 46: func humtum( name : String ) -> String {                  
let display = “ Hello “ + name
                      return  display  }
                Which is proper calling statement for given function
A.      HHumtum( name : “Ravi”) 
B.      humtum()
C.      humtum( name : “Godara”)
D.      None

Q.47: func  add ( num1 : Int , num2 : Int ) -> Int
                {
                let ans = num1 + num2;
        return ans;
  }
Which is proper calling statement
A.      add ( num1 : 5 ,num2 : 10)
B.      add (5 , 10)
C.      add ( num1 : 5 ,  10)
D.      None of the above

Q.48:  func  add ( num1 : Int , num2 : Int ) -> Int
                {
                let ans = num1 + num2;
return ans;
       }
print( add ( num1 : 5 ,num2 : 10) )
What will be the output
A.      5
B.      15
C.      10
D.      Compile Time Error

Q.49: class Area
                {
                var  width  = 1 0
                var height  =  15
                }
Which is the proper syntax to create instance of given               class
A.      let object = new Area()
B.      let object = Area()
C.      object = new Area()
D.      None of the Abvove

Q.50: In the example given in Q.49
           Which is the proper syntax to access properties
A.      object->width
B.      object(width)
C.      object.width
D.      None of the above

Answers: C    C    B     B     D      C     A     B     B     C  
      





No comments:

Post a Comment