Java/Java Mcq Question Set 2 Sample Test,Sample questions

Question:
A method within a class is only accessible by classes that are defined within the same package as the class of the method. Which one of the following is used to enforce such restriction?

1.Declare the method with the keyword public.

2.Declare the method with the keyword private.

3.Do not declare the method with any accessibility modifiers.

4.Declare the method with the keyword public and private.

Posted Date:-2021-10-25 05:16:02


Question:
A package is a collection of

1.Classes and Interfaces

2.Classes

3.Editing tools

4.Editing tools and Interfaces

Posted Date:-2021-10-25 05:16:02


Question:
ate regarding the following classes? class A{private int i; protected int j; } class B extends A{ private int k; protected int m; }

1.An object of B contains data fields j, k, m

2.An object of B contains data fields k, m

3.An object of B contains data fields j, m

4.An object of B contains data fields i, j, k, m

Posted Date:-2021-10-25 05:16:02


Question:
Choose the correct statement : Restriction on static methods are-

1.They cannot refer this or super in any way.

2.They must only access static data.

3.They can only call other static methods.

4.All of the above

Posted Date:-2021-10-25 05:16:02


Question:
Choose the correct statement public class Circle{ private double radius; public Circle(double radius){ radius = radius; } }

1.The program has a compilation error because we cannot assign radius to radius.

2.The program has a compilation error because it does not have a main method.

3.The program does not compile because Circle does not have a default constructor.

4.The program will compile, but we cannot create an object of Circle with a specified radius. The object will always have radius 0.

Posted Date:-2021-10-25 05:16:02


Question:
Executable applet is

1..class file

2..java file

3..java html

4..applet file

Posted Date:-2021-10-25 05:16:02


Question:
Hot java is

1.Web browser

2.Java environment

3.System software

4.IDE

Posted Date:-2021-10-25 05:16:02


Question:
How many keywords are available in java

1.24

2.48

3.96

4.192

Posted Date:-2021-10-25 05:16:02


Question:
How many transaction isolation levels are defined in java.sql.Connection interface

1.6

2.2

3.5

4.3

Posted Date:-2021-10-25 05:16:02


Question:
In Java arrays are

1.objects

2.object references

3.primitive data type

4.None of the above

Posted Date:-2021-10-25 05:16:02


Question:
In which we clone the object and their constituent parts

1.Deep cloning

2.Shallow cloning

3.Both of above

4.None of above

Posted Date:-2021-10-25 05:16:02


Question:
Interfaces helps in which type of inheritance

1.Multiple inheritance

2.Multilevel inheritance

3.Hierarchical inheritance

4.None of above

Posted Date:-2021-10-25 05:16:02


Question:
Java intermediate code is known as

1.Byte code

2.First code

3.Mid code

4.None of above

Posted Date:-2021-10-25 05:16:02


Question:
Java is known as _______stage language

1.1

2.2

3.3

4.4

Posted Date:-2021-10-25 05:16:02


Question:
javah stands for

1.java dissasamebler

2.java header file

3.java interpreter

4.java compiler

Posted Date:-2021-10-25 05:16:02


Question:
Main method parameter has which type of data type

1.int

2.char

3.string

4.double

Posted Date:-2021-10-25 05:16:02


Question:
Name the keyword that makes a variable belong to a class, rather than being defined for each instance of the class.

1.abstract

2.static

3.volatile

4.final

Posted Date:-2021-10-25 05:16:02


Question:
Output : public class Test{ public static void main(String args[]){ String x = "hellow"; int y = 9; System.out.println(x += y); } }

1.hellow9

2.9hellow

3.Compilation error

4.None of these

Posted Date:-2021-10-25 05:16:02


Question:
Smallest individual unit in java program is known as

1.token

2.string

3.literal

4.operator

Posted Date:-2021-10-25 05:16:02


Question:
Suppose a class has public visibility. In this class we define a protected method. Which of the following statements is correct?

1.From within protected methods you do not have access to public methods.

2.This method is only accessible from inside the class itself and from inside all subclasses.

3.In a class, you cannot declare methods with a lower visibility than the visibility of the class in which it is defined.

4.This method is accessible from within the class itself and from within all classes defined in the same package as the class itself.

Posted Date:-2021-10-25 05:16:02


Question:
The object is created with "new" keyword

1.At Compile-time

2.At run-time

3.Depends on the code

4.None of these

Posted Date:-2021-10-25 05:16:02


Question:
The output of the following fraction of code is public class Test{ public static void main(String args[]){ String s1 = new String("Hello"); String s2 = new String("Hellow"); System.out.printl

1.Hellow

2.Hello

3.Compilation error

4.None of these

Posted Date:-2021-10-25 05:16:02


Question:
The String method compareTo() returns

1.TRUE

2.FALSE

3.an int value

4.1

Posted Date:-2021-10-25 05:16:02


Question:
toString() method is defined in

1.java.lang.util

2.java.lang.Object

3.java.lang.String

4.None of these

Posted Date:-2021-10-25 05:16:02


Question:
What do you mean by javap

1.java compiler

2.java debugger

3.java Interpreter

4.java Disassemble

Posted Date:-2021-10-25 05:16:02


Question:
What is jdb

1.java Disassemble

2.java Interpreter

3.java compiler

4.java debugger

Posted Date:-2021-10-25 05:16:02


Question:
What is meaning of jar

1.java array

2.java architecture

3.java archived

4.none of these

Posted Date:-2021-10-25 05:16:02


Question:
What is output of the following code: public class Test{public static void main(String[] args){ int[] x = {120, 200, 016 }; for(int i = 0; i < x.length; i++)System.out.print(x[i] + " "); } }

1.120 200 16

2.120 200 14

3.120 200 016

4.016 is a compile error. It should be written as 16

Posted Date:-2021-10-25 05:16:02


Question:
What is the result of compiling and running the following code? public class Test{ public static void main(String[] args){ int[] a = new int[0]; System.out.print(a.length); } }

1.0

2.1

3.compile error

4.None of the above

Posted Date:-2021-10-25 05:16:02


Question:
What is the value of a[1] after the following code is executed? int[] a = {0, 2, 4, 1, 3}; for(int i = 0; i < a.length; i++) a[i] = a[(a[i] + 3) % a.length];

1.0

2.1

3.2

4.3

Posted Date:-2021-10-25 05:16:02


Question:
What will be the output? public class Test{ public static void main(String[] arg{ int[] a = new int[4]; a[1] = 1; a = new int[2]; System.out.println("a[1] is " + a[1]); } }

1.a[1] is 0

2.a[1] is 1

3.a[1] is 2

4.Compile error

Posted Date:-2021-10-25 05:16:02


Question:
What will be the output? String str1 = "abcde"; System.out.println(str1.substring(1, 3));

1.abc

2.ab

3.bc

4.cba

Posted Date:-2021-10-25 05:16:02


Question:
When you pass an array to a method, the method receives ________ .

1.The length of the array.

2.The reference of the array.

3.A copy of the array.

4.A copy of the first element.

Posted Date:-2021-10-25 05:16:02


Question:
Which command disassembles a class file

1.javacmd

2.javaamd

3.javap

4.java

Posted Date:-2021-10-25 05:16:02


Question:
Which command is used for interpretation of java program

1.Java

2.javap

3.javac

4.none of above

Posted Date:-2021-10-25 05:16:02


Question:
Which driver is called as thin-driver in JDBC

1.Type-1 driver

2.Type-2 driver

3.Type-3 driver

4.Type-4 driver

Posted Date:-2021-10-25 05:16:02


Question:
Which driver is efficient and always preferable for using JDBC applications

1.Type-1 driver

2.Type-2 driver

3.Type-3 driver

4.Type-4 driver

Posted Date:-2021-10-25 05:16:02


Question:
Which is the predefined package

1.Lang package

2.util package

3.io package

4.None of above

Posted Date:-2021-10-25 05:16:02


Question:
Which keyword is used while using interface

1.throw

2.throws

3.extend

4.implements

Posted Date:-2021-10-25 05:16:02


Question:
Which keyword represents object of the present class

1.this

2.static

3.package

4.interface

Posted Date:-2021-10-25 05:16:02


Question:
Which method of java is invoked by JVM to reclaim the inaccessible memory location

1.reclaim() method

2.finalize() method

3.final() method

4.both b and c

Posted Date:-2021-10-25 05:16:02


Question:
Which method of the Applet class displays the result of applet code on screen

1.paint() method

2.main() method

3.run() method

4.drawString() method

Posted Date:-2021-10-25 05:16:02


Question:
Which of the following command is used to compile the Java program

1.java

2.javac

3.javap

4.none of these

Posted Date:-2021-10-25 05:16:02


Question:
Which one of the following is a valid statement?

1.char[] c = new char&l

2.char[] c = new char&l

3.char[] c = new char&l

4.char[] c = new char&l

Posted Date:-2021-10-25 05:16:02


Question:
Which will legally declare, construct, and initialize an array?

1.int [] myList = {

2.int [] myList = (5, 8, 2);

3.int myList [] [] = {4,9,7,0};

4.int myList [] = {4, 3, 7};

Posted Date:-2021-10-25 05:16:02


Question:
____ allows java code to run in the JVM to call and be called by native applications

1.JNI

2.FJI

3.NJI

4.JFI

Posted Date:-2021-10-25 05:16:02


More MCQS

  1. Java Mcq Question Set 1
  2. Java Mcq Question Set 2
  3. Java Mcq Question Set 3
  4. Java Mcq Question Set 4
  5. Java Mcq Question Set 5
  6. Java Mcq Question Set 6
  7. Java Mcq Question Set 7
  8. Java Mcq Question Set 8
  9. Java Mcq Question Set 9
  10. Java Multiple Choice Questions
  11. DATA TYPES IN JAVA
  12. Classes ,Constructor ,Methods,Inheritance
  13. Java Multiple Choice Questions.
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!