.NET

C# Basics

Variables & constants, primitive types, control flow, classes, structs, interfaces, exceptions

25 pertanyaan wawancaraยท
Junior
1

What is a variable in C#?

Jawaban

A variable is a named storage location in memory that holds a value which can be modified during program execution. Each variable has a type that determines what values it can contain and what operations are allowed. Declaring a variable with an explicit type allows the compiler to verify code consistency and optimize memory usage.

2

What is the difference between a variable and a constant in C#?

Jawaban

A variable can have its value changed after initialization, whereas a constant receives a value at compilation that remains fixed throughout the program's lifetime. Constants are declared with the const keyword and must be initialized with a compile-time known value. Using constants for immutable values improves readability and enables compiler optimizations.

3

What is the appropriate type to store a simple integer in C#?

Jawaban

The int type is the most commonly used integer type in C# for storing whole numbers. It occupies 32 bits in memory and can hold values ranging from approximately -2 billion to +2 billion. For most use cases involving counters, indices, or quantities, int provides a good balance between value range and performance.

4

What type should be used to store a true/false value in C#?

5

What is the correct syntax to declare a constant in C#?

+22 pertanyaan wawancara

Kuasai .NET untuk wawancara berikutnya

Akses semua pertanyaan, flashcards, tes teknis, latihan code review dan simulator wawancara.

Mulai gratis