Which of the following options will be the correct function declaration (at Line1) for the given code snippet and sample output?

Code Snippet:

type car struct {
    name string
    brand string
}

__________//Line1__________ {         
    newCar.name = "Civic"
    newCar.brand = "Honda"
}

func main() {
    setCar := car{                  
      name:    "Celica",
      brand: "Toyota",
    }
    setCar.carSwap()                   

    fmt.Printf("Your current car is: %v %v", setCar.brand, setCar.name)
}

Sample Output:

Your current car is: Toyota Celica

func (newCar car) carSwap()

func carSwap(newCar *car)

func (newCar *car) carSwap()

func carSwap(newCar car)

Verified Answer
Correct Option - b

To get all Go Programming Language - Assessment Exam questions Join Group https://bit.ly/infy_premium_group

We're passionate about offering best placement materials and courses!! A one stop place for Placement Materials. We daily post Offcampus updates and Placement Materials.

Qtr No. 213, New Town Yehlanka Indore 454775

admin@prepflix.in