Menu
Topics Index
...
`

Weekend Hack - 12 Jan 2013 - Rs. 200 has these questions


Floating point variables conversion109

What will be the output of the following program?
class FloatConversion
{
    public static void main(String args[])
    {
        int i = 44;
        float f = 98.42f;
        double d = 103.67;
        
        f = i;
        d = f;
        i = (int) d;

        System.out.println("i = " + i);
        System.out.println("f = " + f);
        System.out.println("d = " + d);
    }
}
A. i = 44
f = 44.0
d = 44.0
B. i = 103.67
f = 44
d = 98.42
C. i = 44
f = 44
d = 44
D. i = 44.0
f = 44.0
d = 44.0



Find if the word present in character matrix BiDirectional

Write a program to find if the word is present in the character matrix in any direction. The directions are horizontal, vertical, upward diagonal, downward diagonal and their opposite directions.
Input (char[][], String) Output (Boolean)
B A T C
T O P C
X Y Z W
A C W Z
search word = TOP
true
B A T C
T O P C
X Y Z W
A C W Z
search word = POT
true
Q E A
R M I
X Y Z
search word = MAT
false
Q E A D R
B E G J I
W Z A L N
X V M S U
C J O P T
search word = EAST
true
Q E A D R
B T G J I
W Z S L N
X V M E U
C J O P T
search word = TEST
true
Q E A
R M N
X Y T
search word = ANT
true
Q E N
R M E
X Y T
search word = TEN
true
Q E A D M
B T G E I
W Z R L N
X I M E U
T J O P T
search word = MERIT
true
Q E A D N
B T G A I
W Z V L N
X A M E U
R J O P T
search word = RAVAN
true
class FindWordPresentInCharacterMatrixBiDirectional

{    public static void main(String s[])
    {
        char[][] input = {{'A', 'S', 'C', 'D'}, {'C', 'T', 'A', 'F'}, {'Q', 'M', 'A', 'S'}, {'V', 'X', 'Z', 'C'}};
        System.out.println("CAT is present : " + isWordIsPresentInMatrix(input, "CAT"));

    }


public static boolean isWordIsPresentInMatrix(char[][] matrix, String searchWord) {
//Write code here to find if the word is present in the given matrix.
}

//Write code here if we want create any new methods.
}



© meritcampus 2019

All Rights Reserved.

Open In App