Computer Science, asked by bagadekaju15, 1 year ago

which of the following statements are valid?
1) long num1=10; int num2=num1;

2)int num1=10; long num2=num1;

3)int num1=65; char x= num1;

4)char x= 'a' ; int num 1= x;​

Answers

Answered by dineshkanagarajkrr
53

Answer:

2statement is valid , it's is the correct

Answered by AskewTronics
22

Option 2 and 3 are valid statement

Explanation:

In c or c++ or java programming language, there is a different type of data type which is used to hold the data. There are 2 types of data which are used in the above questions are--

  1. int data type=> It is used to store the data of integer type. It is of two types long int and int.
  2. char data type=> It is used to sore the data of character type.
  • In option 1, The long int variable takes the data of the int type variable. which can be done because both are the integer data type.
  • In option 2, The int variable takes the data of the long int type variable. which can also be done because both are the integer data type.

Hence option 1 and 2 are the correct option because it compiles successfully while the other is not because--

  • In option 3, The char variable takes the data of the int type variable. which can not be done because both are the different data type and it gives a compilation error.
  • In option 4, The int variable takes the data of the char type variable. which can not be done because both are the different data type and it gives a compilation error

Learn more:

  • Data types :https://brainly.in/question/11061146
  • Data types in java : https://brainly.in/question/5332777
Similar questions