Call
whatsapp
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
Cisco Training in Trivandrum, Trinity Technologies

No.1 Training Institute in Kerala

JAVA QUESTIONS : PART 25

How to get UTC time?

Time.getUTC();

Date.getUTC();

Instant.now();

TimeZone.getUTC();

SHOW ANSWER

Which of these is long data type literal?

0x99fffL

ABCDEFG

0x99fffa

99671246

SHOW ANSWER

Which of these can be returned by the operator &?

Integer

Boolean

Character

Integer or Boolean

SHOW ANSWER

Literal can be of which of these data types?

integer

float

boolean

all of the mentioned

SHOW ANSWER

Which of these can not be used for a variable name in Java?

 identifier

keyword

identifier & keyword

none of the mentioned

SHOW ANSWER

What is the output of this program?
class Sample
    {
        public static void main(String args[]) 
        {
            int a[] = {1,2,3,4,5};
        int d[] = a;
        int sum = 0;
        for (int j = 0; j < 3; ++j)
                sum += (a[j] * d[j + 1]) + (a[j + 1] * d[j]);
        System.out.println(sum);
        } 
    }

 38

39

40

41

SHOW ANSWER

What is the output of this program?
    class array_output 
    {
        public static void main(String args[]) 
        {
               int array_variable [] = new int[10];
        for (int i = 0; i < 10; ++i) {
                array_variable[i] = i/2;
                array_variable[i]++;
                System.out.print(array_variable[i] + " ");
                i++;
            }
 
        } 
    }

0 2 4 6 8

1 2 3 4 5

0 1 2 3 4 5 6 7 8 9

1 2 3 4 5 6 7 8 9 10

SHOW ANSWER

What is the output of this program?
class variable_scope 
    {
        public static void main(String args[]) 
        {
            int x;
            x = 5;
            {
            int y = 6;
            System.out.print(x + " " + y);
            }
            System.out.println(x + " " + y);
        } 
    }

5 6 5 6

5 6 5

Runtime error

Compilation error

SHOW ANSWER

Which of these is an incorrect string literal?

“Hello World”

“Hello\nWorld”

“\”Hello World\””

”Hello

World”

SHOW ANSWER

What is the output of this program?
class dynamic_initialization 
    {
        public static void main(String args[]) 
        {
            double a, b;
            a = 3.0;
            b = 4.0;
        double c = Math.sqrt(a * a + b * b);
        System.out.println(c);
        } 
    }

5.0

25.0

7.0

Compilation Error

SHOW ANSWER

Which of these is necessary condition for automatic type conversion in Java?

The destination type is smaller than source type

 The destination type is larger than source type

The destination type can be larger or smaller than source type

None of the mentioned

SHOW ANSWER

What is the prototype of the default constructor of this class?
    public class prototype { }
 

prototype( )

prototype(void)

public prototype(void)

public prototype( )

SHOW ANSWER

What is the error in this code?
    byte b = 50;
     b = b * 50;
 

b cannot contain value 100, limited by its range

* operator has converted b * 50 into int, which can not be converted to byte without casting

b cannot contain value 50

No error in this code

SHOW ANSWER
BACK | NEXT
TRINITY SOFTWARE SOLUTIONS,IInd floor, Radheyam Towers, Gandhari Amman Kovil Road, Pulimood, Trivandrum - 1
0471-2334855 | 2335855 | 9447387064 | 9847003556 info@trinitytechnology.in