41. Determine output:
public class Test {
static void test(float x){
System.out.print("float");
}
static void test(double x){
System.out.print("double");
}
public static void main(String[] args){
test(99.9);
}
}
public class Test {
static void test(float x){
System.out.print("float");
}
static void test(double x){
System.out.print("double");
}
public static void main(String[] args){
test(99.9);
}
}
42. The following fraction of code
double STATIC = 2.5 ;
System.out.println( STATIC );
double STATIC = 2.5 ;
System.out.println( STATIC );
43. What would be the output of the following fraction of code?
int Integer = 34 ;
char String = 'S' ;
System.out.print( Integer ) ;
System.out.print( String ) ;
int Integer = 34 ;
char String = 'S' ;
System.out.print( Integer ) ;
System.out.print( String ) ;
44. What is the output of the following program?
public class Test{
static int x = 10 ;
public static void main(String[] a){
Test test = new Test( ) ;
Test test1 = new Test( ) ;
test.x += 1 ;
System.out.println( test.x + test1.x ) ;
}
}
public class Test{
static int x = 10 ;
public static void main(String[] a){
Test test = new Test( ) ;
Test test1 = new Test( ) ;
test.x += 1 ;
System.out.println( test.x + test1.x ) ;
}
}
45. What will be output of the following program code?
public class Test{
public static void main(String[] a){
short x = 10;
x = x*5;
System.out.print(x);
}
}
public class Test{
public static void main(String[] a){
short x = 10;
x = x*5;
System.out.print(x);
}
}
46. Determine output:
public class Test{
int i = 34;
public static void main(String args[]){
Test t1 = new Test();
Test t2 = new Test();
t1.i = 65;
System.out.print(t1.i);
System.out.print(t2.i);
}
}
public class Test{
int i = 34;
public static void main(String args[]){
Test t1 = new Test();
Test t2 = new Test();
t1.i = 65;
System.out.print(t1.i);
System.out.print(t2.i);
}
}
47. The following program:
public class Test{
static boolean isOK;
public static void main(String args[]){
System.out.print(isOK);
}
}
public class Test{
static boolean isOK;
public static void main(String args[]){
System.out.print(isOK);
}
}
48. In Java, the word true is ................
49. What will the output of the following program?
public class Test{
public static void main(String args[]){
float f = (1 / 4) * 10;
int i = Math.round(f);
System.out.println(i);
}
}
public class Test{
public static void main(String args[]){
float f = (1 / 4) * 10;
int i = Math.round(f);
System.out.println(i);
}
}
50. What is the output for the below code?
class A{
int k;
boolean istrue;
static int p;
public void printValue(){
System.out.print(k);
System.out.print(istrue);
System.out.print(p);
}
}
public class Test{
public static void main(String argv[]){
A a = new A();
a.printValue();
}
}
class A{
int k;
boolean istrue;
static int p;
public void printValue(){
System.out.print(k);
System.out.print(istrue);
System.out.print(p);
}
}
public class Test{
public static void main(String argv[]){
A a = new A();
a.printValue();
}
}
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.