1. What will be the output of the program? int i = (int) Math.random();





Ask Your Doubts Here

Type in
(Press Ctrl+g to toggle between English and the chosen language)

Comments

  • By: guest on 02 Jun 2017 01.26 am
    Math.random() returns a double value greater than or equal to 0 and less than 1. Its value is stored to an int but as this is a narrowing conversion, a cast is needed to tell the compiler that you are aware that there may be a loss of precision. The value after the decimal point is lost when you cast a double to int and you are left with 0.
Show Similar Question And Answers
QA->Name the translatory program which translates the high level language into machine language before running the program?....
QA->An unauthorized program which functions from inside what seems to be an authorized program, thereby concealing what it is actually doing:....
QA->An unauthorized program which functions from inside what seems to be an authorized program, thereby concealing what it is actually doing:....
QA->An unauthorized program which functions from inside what seems to be an authorized program, thereby concealing what it is actually doing:....
QA->An unauthorized program which functions from inside what seems to be an authorized program, thereby concealing what it is actually doing:....
MCQ->What will be the output of the program? #include<stdio.h> int fun(int, int); typedef int (pf) (int, int); int proc(pf, int, int); int main() { printf("%d\n", proc(fun, 6, 6)); return 0; } int fun(int a, int b) { return (a==b); } int proc(pf p, int a, int b) { return ((p)(a, b)); }....
MCQ->Which of the following are valid calls to Math.max? Math.max(1,4) Math.max(2.3, 5) Math.max(1, 3, 5, 7) Math.max(-1.5, -2.8f)....
MCQ->Which of the following statement is correct about the program given below? #include<iostream.h> int BixTest(int x, int y); int BixTest(int x, int y, int z = 5); int main() { cout<< BixTest(2, 4) << endl; return 0; } int BixTest(int x, int y) { return x y; } int BixTest(int x, int y, int z = 5) { return x y z; }....
MCQ->What will be the output of the program? #include<stdio.h> int i; int fun1(int); int fun2(int); int main() { extern int j; int i=3; fun1(i); printf("%d,", i); fun2(i); printf("%d", i); return 0; } int fun1(int j) { printf("%d,", ++j); return 0; } int fun2(int i) { printf("%d,", ++i); return 0; } int j=1;....
MCQ->What will be the output of the following program? #include<iostream.h> class Base { public: int S, A, M; Base(int x, int y) { S = y - y; A = x + x; M = x x; } Base(int, int y = 'A', int z = 'B') { S = y; A = y + 1 - 1; M = z - 1; } void Display(void) { cout<< S << " " << A << " " << M << endl; } }; class Derived : public Base { int x, y, z; public: Derived(int xx = 65, int yy = 66, int zz = 67): Base(x) { x = xx; y = yy; z = zz; } void Display(int n) { if(n) Base::Display(); else cout<< x << " " << y << " " << z << endl; } }; int main() { Derived objDev; objDev.Display(-1); return 0; }....
Terms And Service:We do not guarantee the accuracy of available data ..We Provide Information On Public Data.. Please consult an expert before using this data for commercial or personal use | Powered By:Omega Web Solutions
© 2002-2017 Omega Education PVT LTD...Privacy | Terms And Conditions
Question ANSWER With Solution