All Computer Science Resources
Example Questions
Example Question #1 : Evaluating String Expressions
What is the best way to print out a String variable into a sentence in Swift (iOS)?
Possible Answers:
var str = "Hello"
println("This string says " + str)
var str = "Hello"
println("This string says Hello")
var str = "Hello"
println("This string says str")
var str = "Hello"
println("This string says \(str)")
Correct answer:
var str = "Hello"
println("This string says \(str)")
Explanation:
The \(str) is the best way in Swift. This notation allows for a value of a variable to be input into the sentence. The "+" notation is also correct but is not the best way for Swift. The other two answers print out the words "str" and "Hello" instead of the value of the variable.
All Computer Science Resources
Computer Science Tutors in Top Cities:
Atlanta Computer Science Tutors, Austin Computer Science Tutors, Boston Computer Science Tutors, Chicago Computer Science Tutors, Dallas Fort Worth Computer Science Tutors, Denver Computer Science Tutors, Houston Computer Science Tutors, Kansas City Computer Science Tutors, Los Angeles Computer Science Tutors, Miami Computer Science Tutors, New York City Computer Science Tutors, Philadelphia Computer Science Tutors, Phoenix Computer Science Tutors, San Diego Computer Science Tutors, San Francisco-Bay Area Computer Science Tutors, Seattle Computer Science Tutors, St. Louis Computer Science Tutors, Tucson Computer Science Tutors, Washington DC Computer Science Tutors
Popular Courses & Classes
GRE Courses & Classes in Philadelphia, MCAT Courses & Classes in Denver, GRE Courses & Classes in Atlanta, ACT Courses & Classes in Atlanta, SSAT Courses & Classes in Seattle, ACT Courses & Classes in Dallas Fort Worth, GMAT Courses & Classes in Philadelphia, SAT Courses & Classes in Washington DC, SSAT Courses & Classes in Chicago, Spanish Courses & Classes in Chicago
Popular Test Prep
ACT Test Prep in Atlanta, GMAT Test Prep in New York City, SAT Test Prep in Miami, GRE Test Prep in Washington DC, LSAT Test Prep in Dallas Fort Worth, SSAT Test Prep in San Diego, LSAT Test Prep in Philadelphia, GRE Test Prep in Denver, SAT Test Prep in Atlanta, GMAT Test Prep in Philadelphia