1. What will be the output of the following Java program?
class variable_scope
{
public static void main(String args[])
{
int x;
x = 5;
{
int y = 6;
System.out.print(x + " " + y);
}
System.out.println(x + " " + y);
}
}
class variable_scope
{
public static void main(String args[])
{
int x;
x = 5;
{
int y = 6;
System.out.print(x + " " + y);
}
System.out.println(x + " " + y);
}
}
2. What does LocalTime represent?
3. What will be the output of the following Java program?
class mainclass {
public static void main(String args[])
{
char a = 'A';
a++;
System.out.print((int)a);
}
}
class mainclass {
public static void main(String args[])
{
char a = 'A';
a++;
System.out.print((int)a);
}
}
4. What will be the output of the following Java code snippet?
public class AddDemo
{
public static void main(String args[])
{
BigDecimal b = new BigDecimal("23.43");
BigDecimal br = new BigDecimal("24");
BigDecimal bres = b.add(new BigDecimal("450.23"));
System.out.println("Add: "+bres);
MathContext mc = new MathContext(2, RoundingMode.DOWN);
BigDecimal bdecMath = b.add(new BigDecimal("450.23"), mc);
System.out.println("Add using MathContext: "+bdecMath);
}
}
public class AddDemo
{
public static void main(String args[])
{
BigDecimal b = new BigDecimal("23.43");
BigDecimal br = new BigDecimal("24");
BigDecimal bres = b.add(new BigDecimal("450.23"));
System.out.println("Add: "+bres);
MathContext mc = new MathContext(2, RoundingMode.DOWN);
BigDecimal bdecMath = b.add(new BigDecimal("450.23"), mc);
System.out.println("Add using MathContext: "+bdecMath);
}
}
5. What will be the output of the following Java code?
enum Season
{
WINTER, SPRING, SUMMER, FALL
};
System.out.println(Season.WINTER.ordinal());
enum Season
{
WINTER, SPRING, SUMMER, FALL
};
System.out.println(Season.WINTER.ordinal());
6. Which of these coding types is used for data type characters in Java?
7. What is Truncation in Java?
8. Which of these occupy first 0 to 127 in Unicode character set used for characters in Java?
9. How to convert Date object to String?
10. What will be the output of the following Java program?
class c
{
public void main( String[] args )
{
System.out.println( "Hello" + args[0] );
}
}
class c
{
public void main( String[] args )
{
System.out.println( "Hello" + args[0] );
}
}
Read More Section(Data Types and Variables)
Each Section contains maximum 100 MCQs question on Data Types and Variables. To get more questions visit other sections.