EmSAT Achieve Exam  >  EmSAT Achieve Tests  >  Test: Starting with Java - 1 - EmSAT Achieve MCQ

Test: Starting with Java - 1 - EmSAT Achieve MCQ


Test Description

20 Questions MCQ Test - Test: Starting with Java - 1

Test: Starting with Java - 1 for EmSAT Achieve 2024 is part of EmSAT Achieve preparation. The Test: Starting with Java - 1 questions and answers have been prepared according to the EmSAT Achieve exam syllabus.The Test: Starting with Java - 1 MCQs are made for EmSAT Achieve 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: Starting with Java - 1 below.
Solutions of Test: Starting with Java - 1 questions in English are available as part of our course for EmSAT Achieve & Test: Starting with Java - 1 solutions in Hindi for EmSAT Achieve course. Download more important topics, notes, lectures and mock test series for EmSAT Achieve Exam by signing up for free. Attempt Test: Starting with Java - 1 | 20 questions in 40 minutes | Mock test for EmSAT Achieve preparation | Free important questions MCQ to study for EmSAT Achieve Exam | Download free PDF with solutions
Test: Starting with Java - 1 - Question 1

Which of the following statements is true about Java?

Detailed Solution for Test: Starting with Java - 1 - Question 1

Java is an object-oriented programming language, making option c the correct choice.

Test: Starting with Java - 1 - Question 2

What is the correct order of the Java program's execution?

Detailed Solution for Test: Starting with Java - 1 - Question 2

The correct order of execution in Java is Declaration, Initialization, and Execution, making option a the correct choice.

1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: Starting with Java - 1 - Question 3

Which of the following data types is used to store a single character in Java?

Detailed Solution for Test: Starting with Java - 1 - Question 3

The char data type is used to store a single character in Java, making option a the correct choice.

Test: Starting with Java - 1 - Question 4

What is the output of the following code snippet?
int a = 5;
int b = 7;
int c = a + b;
System.out.println(c);

Detailed Solution for Test: Starting with Java - 1 - Question 4

The code snippet adds two integers and assigns the sum to variable c, which is then printed. The output is 12, making option a the correct choice.

Test: Starting with Java - 1 - Question 5

Which of the following is not a valid identifier in Java?

Detailed Solution for Test: Starting with Java - 1 - Question 5

123abc is not a valid identifier in Java as it starts with a digit, making option c the correct choice.

Test: Starting with Java - 1 - Question 6

Which of the following is a valid literal representation of a double data type in Java?

Detailed Solution for Test: Starting with Java - 1 - Question 6

The valid literal representation of a double data type in Java is 10.5d, making option b the correct choice.

Test: Starting with Java - 1 - Question 7

What is the output of the following code snippet?
int x = 5;
int y = 2;
double result = x / y;
System.out.println(result);

Detailed Solution for Test: Starting with Java - 1 - Question 7

The valid literal representation of a double data type in Java is 10.5d, making option b the correct choice.

Test: Starting with Java - 1 - Question 8

What is the purpose of the "static" keyword in Java?

Detailed Solution for Test: Starting with Java - 1 - Question 8

The "static" keyword in Java is used to define a class-level variable or method, making option b the correct choice.

Test: Starting with Java - 1 - Question 9

Which of the following is not a valid Java access modifier?

Detailed Solution for Test: Starting with Java - 1 - Question 9

default is a valid Java access modifier, making option c the correct choice.

Test: Starting with Java - 1 - Question 10

Which of the following is not a Java keyword?

Detailed Solution for Test: Starting with Java - 1 - Question 10

main is not a Java keyword, making option b the correct choice.

Test: Starting with Java - 1 - Question 11

What is the output of the following code snippet?
int x = 5;
x++;
System.out.println(x++);

Detailed Solution for Test: Starting with Java - 1 - Question 11

The code snippet uses the post-increment operator, which first prints the value and then increments it. The output is 6, making option b the correct choice.

Test: Starting with Java - 1 - Question 12

What is the output of the following code snippet?
int x = 10;
int y = 3;
System.out.println(x % y);

Detailed Solution for Test: Starting with Java - 1 - Question 12

The % operator returns the remainder of the division. In this case, 10 divided by 3 leaves a remainder of 1, making option b the correct choice.

Test: Starting with Java - 1 - Question 13

What is the output of the following code snippet?
String str1 = "Hello";
String str2 = "World";
String result = str1 + " " + str2;
System.out.println(result.length());

Detailed Solution for Test: Starting with Java - 1 - Question 13

The code snippet concatenates two strings and assigns the result to the variable result. The length() method returns the length of the resulting string, which is 11, making option b the correct choice.

Test: Starting with Java - 1 - Question 14

What is the output of the following code snippet?
int[] numbers = {1, 2, 3, 4, 5};
int sum = 0;
for (int i = 0; i < numbers.length; i++) {
    sum += numbers[i];
}
System.out.println(sum);

Detailed Solution for Test: Starting with Java - 1 - Question 14

The code snippet initializes an array of integers and calculates the sum of its elements using a for loop. The output is 15, making option b the correct choice.

Test: Starting with Java - 1 - Question 15

What is the output of the following code snippet?
int x = 5;
int y = 2;
int result = x / y;
System.out.println(result * 2);

Detailed Solution for Test: Starting with Java - 1 - Question 15

The variables x and y are of the int data type, and the division operator (/) performs integer division. The result is 2, and multiplying it by 2 gives 4, making option c the correct choice.

Test: Starting with Java - 1 - Question 16

What will be the output of the following code?
public class Test {
    public static void main(String[] args) {
        int x = 10;
        int y = 20;
        swap(x, y);
        System.out.println("x = " + x + ", y = " + y);
    }
    
    public static void swap(int a, int b) {
        int temp = a;
        a = b;
        b = temp;
    }
}

Detailed Solution for Test: Starting with Java - 1 - Question 16

In Java, primitive types are passed by value, so the swap method doesn't affect the original variables x and y. Therefore, the output is x = 10, y = 20, making option a the correct choice.

Test: Starting with Java - 1 - Question 17

What will be the output of the following code?
public class Test {
    public static void main(String[] args) {
        String str = "Hello";
        modifyString(str);
        System.out.println(str);
    }
    
    public static void modifyString(String s) {
        s += " World";
    }
}

Detailed Solution for Test: Starting with Java - 1 - Question 17

String objects in Java are immutable, so modifying the string inside the modifyString method doesn't affect the original string. Therefore, the output is Hello, making option a the correct choice.

Test: Starting with Java - 1 - Question 18

What will be the output of the following code?
public class Test {
    public static void main(String[] args) {
        int x = 5;
        changeValue(x);
        System.out.println(x);
    }
    
    public static void changeValue(int num) {
        num += 10;
    }
}

Detailed Solution for Test: Starting with Java - 1 - Question 18

The method changeValue operates on a copy of the variable x, so modifying the copy doesn't affect the original variable. Therefore, the output is 5, making option a the correct choice.

Test: Starting with Java - 1 - Question 19

What will be the output of the following code?
public class Test {
    public static void main(String[] args) {
        int[] numbers = {1, 2, 3, 4, 5};
        changeArray(numbers);
        System.out.println(numbers[0]);
    }
    
    public static void changeArray(int[] arr) {
        arr[0] = 10;
    }
}

Detailed Solution for Test: Starting with Java - 1 - Question 19

Arrays are passed by reference in Java, so modifying the array inside the changeArray method affects the original array. Therefore, the output is 10, making option d the correct choice.

Test: Starting with Java - 1 - Question 20

What will be the output of the following code?
public class Test {
    public static void main(String[] args) {
        int x = 5;
        int y = 10;
        x = y;
        y = x;
        System.out.println("x = " + x + ", y = " + y);
    }
}

Detailed Solution for Test: Starting with Java - 1 - Question 20

The code assigns the value of y to x and then assigns the value of x to y, effectively swapping their values. Therefore, the output is x = 5, y = 5, making option c the correct choice.

Information about Test: Starting with Java - 1 Page
In this test you can find the Exam questions for Test: Starting with Java - 1 solved & explained in the simplest way possible. Besides giving Questions and answers for Test: Starting with Java - 1, EduRev gives you an ample number of Online tests for practice

Top Courses for EmSAT Achieve

Download as PDF

Top Courses for EmSAT Achieve