shadab alam


{ City } bokaro
< Country > india
* Profession * fresher
User No # 28578
Total Questions Posted # 0
Total Answers Posted # 7

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 97
Users Marked my Answers as Wrong # 35
Questions / { shadab alam }
Questions Answers Category Views Company eMail




Answers / { shadab alam }

Question { Choice Solutions, 6380 }

what is a constructor?


Answer

It is very Important to know that
---------------------------------------
Constructor is generally used to create the new instance of
a class.

Constructor is special type of method that is used to
initialized the member variable and It has same name as the
class Name.It does not have return type.

Is This Answer Correct ?    0 Yes 0 No

Question { TCS, 11845 }

When static constructor is invoked?


Answer

static costructor of a class invoked automatically when
class is loded provided Main method is given.There is no
need to create instance of a class.

we can prove it by following program in c#

using System;
class aa
{
static aa()
{
Console.Write("without instance");
}
public static void Main()
{

}

}


output will be
---------------
without instance

Is This Answer Correct ?    13 Yes 0 No


Question { 4535 }

Program to check whether a word is in all capital letters


Answer

using System;
class a
{
public static void Main()
{
Console.WriteLine("Enter a word ");
string s=Console.ReadLine();
char []c=s.ToCharArray();
int ctr=0;
for(int i=0;i {
if(c[i]>=65 && c[i]<=90)
{
ctr++;
}
else
{
ctr=0;
}

}
if(ctr>0)
{
Console.WriteLine("word are in
capital letter");

}
else
{
Console.WriteLine("word are not in
all capital letter");
}
}
}

Is This Answer Correct ?    2 Yes 2 No

Question { Aspire, 9105 }

can we make a class static without using static keyword?


Answer

yes we can make a class static without using static keyword
We can prove it by following program.

we konw that static member of a class can be accessed by
using the class name now I will do it without static
keyword specify in sub class

Like a.abc.add()
where a is class name and abc is also class name but
without static keyword.But it executed successfully.
this proves that inner class is a static class.


using System;
static class a
{



public static void my()
{
Console.WriteLine("outer class's method");
}
class abc
{


public static void add()
{
Console.WriteLine("Inner class's
method");
}
}
public static void Main()
{

a.my();
a.abc.add();
}


}

Is This Answer Correct ?    6 Yes 3 No

Question { 16945 }

Can two catch blocks be executed?


Answer

Yes Yes
Two catch block can be executed at one time.
The example is given bellow .

using System;
class ab
{


public static void Main()

{
int []arr=new int[2]{2,3};
int a=9;
int b=0;
try
{
int r=a/b;
}
catch(DivideByZeroException d)
{
Console.WriteLine(d.ToString());
}
catch(Exception aa)
{
Console.WriteLine(aa.ToString());
}
finally
{
Console.WriteLine(arr[3]);
}

}

}


output will be
-------------
System.DivideByZeroException: Attempted to divide by zero.
at ab.Main()

Unhandled Exception: System.IndexOutOfRangeException: Index
was outside the boun
ds of the array.
at ab.Main()

Is This Answer Correct ?    6 Yes 16 No

Question { 16945 }

Can two catch blocks be executed?


Answer

yes two catch block can be executed .

Sorry for privious Error!whrer two catch block are not
executd but this time it has been executed

Now This is right answer here two


using System;
class a
{
public static void Main()
{
int a=8;
int b=0;
int [] arr=new int[]{1,2};
try
{
Console.WriteLine(a/b);
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
Console.WriteLine("Hello");
}
finally
{ try
{
Console.WriteLine(arr[2]);
}
catch(IndexOutOfRangeException d)
{
Console.WriteLine(d.ToString
()+ "hello");
Console.WriteLine("Hello");
}
}
}
}


output will be
----------------
System.DivideByZeroException: Attempted to divide by zero.
at a.Main()
Hello
System.IndexOutOfRangeException: Index was outside the
bounds of the array.
at a.Main()hello
Hello

Is This Answer Correct ?    12 Yes 3 No

Question { 20137 }

What is the need to declare main() method as static in Java?


Answer

static keyword specifies that there is no need of instance
to call static method and it's information is contained by
JVM that calls the static method.That's why we declare main
method as static so that it can be called automaticlly.

Is This Answer Correct ?    58 Yes 11 No