My Report

Java Programming Practice Test 1


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. Which of these is long data type literal?

2. How to format date from one form to another?

3. Which of these can be returned by the operator &?

4. What will be the output of the following Java program?

    class evaluate 
    {
        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);
        } 
    }

5. Which class is a library of functions to perform arithmetic operations of BigInteger and BigDecimal?

6. What is the type of variable 'b' and 'd' in the following Java snippet?

int a[], b;
int []c, d;

7. With x = 0, which of the following are legal lines of Java code for changing the value of x to 1?

   1. x++;
   2. x = x + 1;
   3. x += 1;
   4. x =+ 1;

8. Decrement operator, −−, decreases the value of variable by what number?

9. How to convert a String to a Date object?

10. BigDecimal is a part of which package?


 

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.