More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know.
Ans. public static void printTriagle(int n)
{
// outer loop to handle number of rows
// n in this case
for (int i=0; i1; j--)
{
// printing spaces
System.out.print(" ");
}
// inner loop to handle number of columns
// values changing acc. to outer loop
for (int j=0; j<=i; j )
{
// printing stars
System.out.print("* ");
}
// ending line after each row
System.out.println();
}
}
// Driver Function
public static void main(String args[])
{
int n = 5;
printTriagle(n);
}
Help us improve. Please let us know the company, where you were asked this question :
Ans. Which group of bytes represent which character is defined by character encoding. So when reading character by character from a stream of bytes using Reader, specifying character encoding becomes significant as the same group of bytes can represent different character in different character encoding(Eg UTF-8 and UTF-16 etc.)
Help us improve. Please let us know the company, where you were asked this question :
Ans. The regular behavior of exception handling will occur. It will look for any immediate catch handler and if none is provided, it would be transmitted to the callers until a catch handler is found or it's out of main function.
Help us improve. Please let us know the company, where you were asked this question :
Ans. final can be used for variables , methods and class. A final variable cannot be changed , a final method cannot be overridden , a final class cannot be inherited.
Finally is a block which is used after Try and catch, a finally block is always executed.
Help us improve. Please let us know the company, where you were asked this question :
Ans. A compiler directive is an instruction that tells the JVM how compilation should occur. A directive provides method-context precision in controlling the compilation process.
Help us improve. Please let us know the company, where you were asked this question :
Ans. null is a literal similar to true and false in Java. These are not keywords because these are the values of something. As null is the value of a reference variable, true is the value of a boolean variable.
Help us improve. Please let us know the company, where you were asked this question :
Ans. 1. The problem with double (x*100)/100 doesn't return exact x but few fractions lesser than x and then if you are using floor rounding , it makes a big difference
2. Rounding only after getting a result vs rounding each outcome of 2 operand make difference
3. Usage of inappropriate Rounding mode and Rounding scale.
4. Results with double and BigDecimal
Help us improve. Please let us know the company, where you were asked this question :