# Golang Operators – Aptitude Questions and Answers

Golang Operators – Aptitude Questions and Answers: This section contains aptitude questions and answers on Golang Operators.
Submitted by Nidhi, on February 19, 2022

1) Which is not a bitwise operator?

2) What will be the output of the following program?
```package main

import "fmt"

func main() {
var X = 10
var Y = 2
var Z = 0

Z = X & Y

fmt.Printf("%d", Z)
}
```

3) What will be the output of the following program?
```package main

import "fmt"

func main() {
var TV = 0x01
var MOBILE = 0x02

var item = 0x00
var temp = 0x00

item = item | TV
item = item | MOBILE

fmt.Printf("I have purchased ...:")
temp = (item & MOBILE)
if temp != 0 {
fmt.Printf(" MOBILE, ")
}

temp = (item & TV)
if temp != 0 {
fmt.Printf(" TV")
}
}
```

4) What will be the output of the following program?
```package main

import "fmt"

func main() {
var val = 0x04

val = val | 0x04

fmt.Printf("%d,", val)

val |= 0x01

fmt.Printf("%d", val)
}
```

5) What will be the output of the following program?
```package main

import "fmt"

func main() {
var val = 10 ^ 2
fmt.Printf("val: %d", val)
}
```

6) What will be the output of the following program?
```package main

import "fmt"

func main() {
var val = 0x0f;

val &= ~0x02;
fmt.Printf("%d",val);
}
```

7) Which Bitwise Operator can be used to check whether a number is EVEN or ODD quickly?

8) Left shift (<<) and Right shift (>>) operators are equivalent to ___ by 2.

9) What will be the output of the following program?
```package main

import "fmt"

func main() {
var A int  = 65;
var B char = (char)A;

fmt.Printf("%c\n",B);
}
```

10) What will be the output of the following program?
```package main

import "fmt"

func main() {
var A float32 = 65.12
var B int = int(A)

fmt.Printf("%d\n", B)
}
```

11) What will be the output of the following program?
```package main

import "fmt"

func main() {
var A float32  = 65.12;
var B int      = (int)A;

fmt.Printf("%d\n",B);
}
```

12) What will be the output of the following program?
```package main

import "fmt"

func main() {
var A float32 = 65.12
var B float64 = float(A)

fmt.Printf("%f\n", B)
}
```

13) What will be the output of the following program?
```package main

import "fmt"

func main() {
var num int = int('A' + 2)

fmt.Printf("%d\n", num)
}
```

Preparation

What's New

Top Interview Coding Problems/Challenges!