Home / Interview / F# :: General Questions

Interview :: F#

21)

What are the options in F#?

Options type is used when there is no value present for function or variable. It provides an expression Some and a value None for handling the empty values or variables.

EXAMPLE

22)

What is Generics in F#?

F# allows you to write a generic function, method, type, variable, etc. It helps to avoid repeating of code for each type. By writing generic code, you can apply it for any type or value.

EXAMPLE

23)

What are the Records in F#?

Records are used to store elements in the form of label and value. It can store any data. You are not bound to store same type values as a list. Records are immutable by default so you can't modify original records.

EXAMPLE

24)

What is Enumeration in F#?

Enumeration is popularly known as enums. It is a combination of label and value pair. Labels are assigned to a subset of the values. You can use them in place of literals to make the code more readable and maintainable.

EXAMPLE

25)

What are Reference cells in F#?

Reference cells refer to memory locations. It allows you to create mutable values. F# uses immutable data structure by default.

EXAMPLE

26)

What is a structure in F#?

The F# structure is a data structure which is used to organize data, and it is value types and efficient than class. It does not allow let binding, so you must declare fields by using val keyword.

EXAMPLE

27)

What is Discriminated Union in F#?

It is a useful data structure. It helps to store heterogeneous data. The Union is used to represent tree data structures. It provides cases, and each case consists of heterogeneous data.

EXAMPLE

28)

What is Object in F#?

The Object is a real-world entity. It can be anything like - cell phone, car, football, etc.

The Object is an instance of the class we can access all the members of the class by using object of this class.

Let's see an example of how to create an object in F#.

29)

What is a class in F#?

The Class is a template or blueprint of an object. It is used to encapsulate data members and member methods. It can contain fields, methods, constructor, static method, etc.

EXAMPLE

30)

What is a constructor in F#?

In F#, Constructor is somewhat different than other .Net languages. There are always primary constructors that may or may not have parameters. The Scope of these parameters is throughout the class.

EXAMPLE