Java MCQ test - Type casting | Java Quiz on Type casting



Check your Java concepts on type casting with our free online Java test series. Evaluate type-casting concepts in Java by giving this online test that covers topics like narrowing and widening conversions, upcasting, downcasting, etc.


Java type casting MCQ test

Topic- Java - Type casting

The test consists of 11 questions.

No negative marking for this test.

No Time limit

The pass percentage is 70%

The correct answer with a description will be displayed after the answer has been marked.

Submit the test to calculate your score once you are done with all the questions.

Complexity Level- Moderate




Q1: A type conversion in which the value of a narrower primitive data type is converted to a value of a broader primitive data type is called ________














Q2: A type conversion in which a broader primitive datatype is assigned to a narrower (smaller) data type is called ________














Q3: Assigning an int data type to a double data type will be considered as ________














Q4: Assigning a double type of data to an int type will be considered as _________














Q5: The conversions between reference types where super type gets converted to subtype are called _______















Q6: Casting between a primitive data type and a reference type is not permitted in Java.

Select whether the statement is true or false:











Q7: Boolean values can also be cast to other data values and vice versa:


Select True or False:











Q8: Assigning a broader datatype to a smaller datatype requires an explicit cast:


Select True or False:










Q9: What will be the output of the below java program?

class helloworld {

static int i;
static double d;

public static void main(String[] args)
{
d=10;
i=d;
System.out.println("i = "+i);
}
}














Q10: What will be the output of the below java program?

class helloworld {

static int i;
static double d;

public static void main(String[] args)
{
i=10;
d=i;
System.out.println("d = "+d);
}
}














Q11: What will be the output of the below program?

class suprClass {

int i=200;
public void suprFunc(){
System.out.println("value of i in super class = "+i);
}
}

class subClass extends suprClass{
int i=9;
public void suprFunc(){
System.out.println("value of i in sub class = "+i);
}
}

class demo{

public static void main(String[] args){
subClass subc = new suprClass();
subc.suprFunc();
}
}