π Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (178K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
1. What is the output of the following expression in C#?
5 + 3 * 2
Answer:
Explanation:
According to the order of operations in C#, multiplication is performed before addition. So, 3 * 2 is calculated first, making the expression 5 + 6, which equals 11.
2. In C#, which operator is used for concatenating two strings?
Answer:
Explanation:
In C#, the '+' operator is used to concatenate two strings.
3. What is the purpose of the '??' operator in C#?
Answer:
Explanation:
The '??' operator in C# is the null-coalescing operator, used to return the left-hand operand if it is not null, or the right-hand operand otherwise.
4. Which operator in C# is used to check type compatibility?
Answer:
Explanation:
The 'is' operator in C# is used to check if an object is compatible with a given type.
5. What does the following C# code return?
int x = 10;
int result = x++;
Answer:
Explanation:
The post-increment operator (x++) increases the value of x after its current value has been assigned to result. So, result gets the value 10.
6. Which of the following is the correct use of the conditional (ternary) operator in C#?
Answer:
Explanation:
The correct syntax for the ternary operator in C# is 'condition ? true_expression : false_expression'.
7. What is the purpose of the '%' operator in C#?
Answer:
Explanation:
The '%' operator in C# is used to find the remainder after division of one number by another.
8. In C#, which operator is used for bitwise AND operation?
Answer:
Explanation:
The '&' operator in C# is used for bitwise AND operations.
9. What will be the result of the expression (true || false) in C#?
Answer:
Explanation:
The logical OR operator '||' returns true if either of its operands is true. Here, since one operand is true, the result is true.
10. Which operator in C# is used to explicitly convert a type?
Answer:
Explanation:
In C#, parentheses are used for explicit type conversion, also known as casting.
11. How does the 'as' operator differ from casting in C#?
Answer:
Explanation:
The 'as' operator in C# is used for safe type conversion. It returns null if the conversion cannot be performed, unlike explicit casting which throws an exception.
12. What is the precedence of the logical AND ('&&') operator compared to the logical OR ('||') operator in C#?
Answer:
Explanation:
In C#, the logical AND operator ('&&') has higher precedence than the logical OR operator ('||').
13. Which of the following operators can be overloaded in C#?
Answer:
Explanation:
In C#, operators like '+' can be overloaded, but conditional (?:), logical AND (&&), and null-coalescing (??) operators cannot be.
14. What will be the result of the expression (5 & 3) in C#?
Answer:
Explanation:
The bitwise AND of 5 (0101 in binary) and 3 (0011 in binary) is 0001 in binary, which is 1 in decimal.
15. What is the output of the following C# code?
int a = 10;
int b = 3;
int result = a / b;
Answer:
Explanation:
In C#, the division of two integers results in an integer. The fractional part is discarded, so 10 / 3 gives 3.
My Top and Bestseller Udemy Courses. The sale is going on with a 70 - 80% discount. The discount coupon has been added to each course below:
Build REST APIs with Spring Boot 4, Spring Security 7, and JWT
[NEW] Learn Apache Maven with IntelliJ IDEA and Java 25
ChatGPT + Generative AI + Prompt Engineering for Beginners
Spring 7 and Spring Boot 4 for Beginners (Includes 8 Projects)
Available in Udemy for Business
Building Real-Time REST APIs with Spring Boot - Blog App
Available in Udemy for Business
Building Microservices with Spring Boot and Spring Cloud
Available in Udemy for Business
Java Full-Stack Developer Course with Spring Boot and React JS
Available in Udemy for Business
Build 5 Spring Boot Projects with Java: Line-by-Line Coding
Testing Spring Boot Application with JUnit and Mockito
Available in Udemy for Business
Spring Boot Thymeleaf Real-Time Web Application - Blog App
Available in Udemy for Business
Master Spring Data JPA with Hibernate
Available in Udemy for Business
Spring Boot + Apache Kafka Course - The Practical Guide
Available in Udemy for Business
Comments
Post a Comment
Leave Comment