Computer Science › Variable Declarations
#include
using namespace std;
int main()
{
string str("ComputerScience");
string mystr;
str = str + "SampleQuestionCS";
mystr = str.substr(7,8);
return 0;
}
What is the value of mystr after this code is run?
int x=2;
double y=2.1;
float z=3.0;
int c=(x*y) + z;
What is the value of c
Which of these produce a typecasting error?
float f = double d;
double d = int i;
int i = byte b;
long l = short s;
What are the 3 different manners (in terms of accessibilitiy) in which you can declare a variable and what are the differences between the 3?
// ^ is Exclusive-Or (XOR) operator
x = x ^ y
y = x ^ y
x = x ^ y
What is the effect of the above snippet of code?
Which of the following code snippets declares an array of integers using an array literal?
What is the difference between double and int?
Which of the following declares a String array of size i? (Presume Java syntax.)