AmbitionBox
Discover Best Places to work in India
Discover best places to work
Compare & find best workplace
Bring your workplace to life
Highlight your company's perks
Read reviews for 6L+ companies
Rate your former or current company
Discover salaries for 8L+ companies
Calculate your take home salary
Check your market value
Help other jobseekers
Read interviews for 90K+ companies
Interviews questions for 1K+ colleges
Contribute your interview questions
C# Programming
Correct Declaration of Values to variables ‘a’ and ‘b’?
int a = 32, b = 40.6
int a = 42; b = 40
int a = 32; int b = 40
int a = b = 42
a) Although,declaration of ‘b’ and ‘a’ are correct but initialization of value to ‘b’ should be ‘int’ datatype not float. b) Missing declaration type of ‘b’. c) correctly declared datatypes ‘a’ and ‘b’. d) ‘b’ can’t be assigned values before declaration.
Select error in the given program :
1.
static Void Main(String[] args)
2.
{
3.
constint m =100;
4.
int n =10;
5.
constint k = n /5*100* n ;
6.
Console.WriteLine(m * k);
7.
Console.ReadLine();
8.
}
‘k’ should not be declared constant
Expression assigned to ‘k’ should be constant in nature
Expression (m * k) is invalid
m ‘ is declared in invalid format
’k’ should be declared as const int k = 10/5 * 100*10 i.e only constant values should be assigned to a constant. Output :Error 1 – The expression being assigned to ‘k’ must be constant.
Correct output for code is?
staticvoid Main(string[] args)
float a = 10.553f;
long b = 12L;
int c;
c = Convert.ToInt32(a + b);
Console.WriteLine(c);
23.453
22
23
22.453
The two datatype ‘float’ and ‘long’ after arithmetic operation completely converted to nearest whole number 23. Output : 23.
How many Bytes are stored by ‘Long’ Datatype in C# .net?
8
4
2
1
‘Long’ is the datatype keyword used for storing data of unlimited length so by definition its size is always maximum i.e 8.
Which Conversion function of ‘Convert.TOInt32()’ and ‘Int32.Parse()’ is efficient? 1) Int32.Parse() is only used for strings and throws argument exception for null string 2) Convert.Int32() used for datatypes and returns directly ‘0’ for null string
Both 1 & 2
None of the mentioned
Convenient for every datatype so mostly preferred
Join India’s largest community to research company culture
Are you a student or working professional?
Student/Never worked
I am a student/I have never worked
Working Professional
I am working/I have worked before
What are your preferred job locations?
Popular Cities
Other Cities
Follow your preferred designations/job profiles
Suggestions based on your job profile
vs
Similar Companies