CoderMantra

Menu
  • Home
  • Quiz
  • How-To
  • Q/A
  • Blog

java exam

0 votes, 0 avg
363
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

Java Questions

1 / 15

1. What will be the output of the following Java code?

class Char {
public static void main(String args[]) {
char ch1, ch2;
ch1 = 88; // code for X
ch2 = 'Y';
System.out.print("ch1 and ch2: ");
System.out.println(ch1 + " " + ch2);
}
} 

2 / 15

2. Which of these statements are incorrect?

3 / 15

3. How is Date stored in database?

4 / 15

4. What is the function of javap command?

5 / 15

5. Which of the following are not java modifiers?

6 / 15

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

7 / 15

7. Find the output of the following code.

        import java.util.*;

        class Collection_iterators 

        {

            public static void main(String args[]) 

            {

                LinkedList list = new LinkedList();

                list.add(new Integer(2));

                list.add(new Integer(8));

                list.add(new Integer(5));

                list.add(new Integer(1));

                Iterator i = list.iterator();

                Collections.reverse(list);

    	    Collections.sort(list);

                while(i.hasNext())

    	        System.out.print(i.next() + " ");

            }

        }

8 / 15

8. What is the default value of String variable?

9 / 15

9. Find the output of the following code.

        class box 

        {

            int width;

            int height;

            int length;

        } 

        class main

        {

            public static void main(String args[]) 

            {        

                 box obj = new box();

                 obj.width = 10;

                 obj.height = 2;

                 obj.length = 10;

                 int y = obj.width * obj.height * obj.length; 

                 System.out.print(y);

            } 

        }

10 / 15

10. Find the output of the following code.

        class bool_operator 

        {

            public static void main(String args[]) 

            {    

                 boolean a = true;

                 boolean b = !true;

                 boolean c = a | b;

     	     boolean d = a & b;

                 boolean e = d ? b : c;

                 System.out.println(d + " " + e);

            } 

        }

11 / 15

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

        class recursion 

        {

            int fact(int n) 

            {

                int result;

                if (n == 1)

                    return 1;

                result = fact(n - 1) * n;

                return result;

            }

        } 

        class Output 

        {

            public static void main(String args[]) 

            {

                recursion obj = new recursion() ;

                System.out.print(obj.fact(5));

            }

        }

12 / 15

12. Find the output of the following code.

        class leftshift_operator 

        {

            public static void main(String args[]) 

            {        

                 byte x = 64;

                 int i;

                 byte y; 

                 i = x << 2;

                 y = (byte) (x << 2);

                 System.out.print(i + " " + y);

            } 

        }

13 / 15

13. Which of these data types is used to store command line arguments?

14 / 15

14. What will be the output of the following Java code?

        class static_out 

        {

            static int x;

     	static int y;

            void add(int a, int b)

            {

                x = a + b;

                y = x + b;

            }

        }    

        public class static_use 

        {

            public static void main(String args[])

            {

                static_out obj1 = new static_out();

                static_out obj2 = new static_out();   

                int a = 2;

                obj1.add(a, a + 1);

                obj2.add(5, a);

                System.out.println(obj1.x + " " + obj2.y);     

            }

       }

15 / 15

15. Which of these is correct about passing an argument by call-by-value process?

Your score is

The average score is 36%

LinkedIn Facebook VKontakte
0%

By Wordpress Quiz plugin

Category

  • AI
  • Assignments
    • C Language Assignments
    • C++ Assignments
    • Java Assignments
    • Python Assignments
  • C Programming
  • c-plus-plus-Assignments
  • C++
  • Core Java
  • Data Structure
  • Data Structure In C++
  • data structures
  • How To
  • Java-Assignments
  • node js questions
  • nodejs assignments
  • nodejs Projects
  • Practice Questions
  • Python Tutorial
  • Python-Assignments
  • Questions
  • Quiz
  • sql-functions
  • SQL-Tutorial
  • Tkinter Tutorial
  • Uncategorized
  • What Is
  • Why

Archives

  • December 2025
  • November 2025
  • October 2025
  • September 2025
  • July 2025
  • April 2025
  • October 2024
  • September 2024
  • June 2024
  • April 2024
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • May 2022
  • November 2021
  • May 2021
  • March 2021
  • November 2020
  • October 2020
  • August 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • September 2019
  • August 2019
  • May 2019
  • March 2019
  • February 2019
  • January 2019
About CoderMantra

Coder Mantra is a unique e-learning website, offers a tutorial of different popular programming languages with examples. The code on this popular tutorial website is tested and executed.

Latest Posts
Heap in Data Structures December 31, 2025
AVL Tree in Data Structures December 29, 2025
Binary Search Tree (BST) in Data Structures December 24, 2025
Binary Tree in Data Structures December 17, 2025
Contact Us

info@codermantra.com

admin@codermantra.com

© 2020 Coder Mantra . All Rights Reserved
About | Privacy Policy | Terms | Contact