Java Programming MCQ (Multiple Choice Questions) - SchoolingAxis

Java Programming MCQ (Multiple Choice Questions)

 Que-  Which of the following statements are incorrect?

a. static methods can call other static methods only

b. static methods must only access static data

c. static methods can not refer to this or super in any way

d. when object of class is declared, each object contains its own copy of static variables


Answer- when object of class is declared, each object contains its own copy of static variables


Que-  Which of the following statements are incorrect?

a. Variables declared as final occupy memory

b. final variable must be initialized at the time of declaration

c. Arrays in java are implemented as an object

d. All arrays contain an attribute-length which contains the number of elements stored in the array


Answer- Variables declared as final occupy memory


Que-  Which of these methods must be made static?

a. main()

b. delete()

c. run()

d. finalize()


Answer- main()


Que-  String in Java is a?

a. class

b. object

c. variable

d. character array


Answer- class


Que-  Which of these method of String class is used to obtain character at specified index?

a. char()

b. Charat()

c. charat()

d. charAt()


Answer- charAt()


Que-  Which of these keywords is used to refer to member of base class from a subclass?

a. upper

b. super

c. this

d. none of the mentioned


Answer- super


Que-  Which of these method of String class can be used to test to strings for equality?

a. isequal()

b. isequals()

c. equal()

d. equals()


Answer- equals()


Que-  Which of the following statements are incorrect?

a. String is a class

b. Strings in java are mutable

c. Every string is an object of class String

d. Java defines a peer class of String, called StringBuffer, which allows string to be altered


Answer- Strings in java are mutable


Que-  Which of these is the method which is executed first before execution of any other thing takes place in a program?

a. main method

b. finalize method

c. static method

d. private method


Answer- static method


Que-  What is the process of defining more than one method in a class differentiated by parameters?

a. Function overriding

b. Function overloading

c. Function doubling

d. None of the mentioned


Answer- Function overloading


Que-  Which of these can be used to differentiate two or more methods having the same name?

a. Parameters data type

b. Number of parameters

c. Return type of method

d. All of the mentioned


Answer- All of the mentioned


Que-  Which of these data type can be used for a method having a return statement in it?

a. void

b. int

c. float

d. both int and float


Answer- both int and float


Que-  Which of these statement is incorrect?

a. Two or more methods with same name can be differentiated on the basis of their parameters data type

b. Two or more method having same name can be differentiated on basis of number of parameters

c. Any already defined method in java library can be defined again in the program with different data type of parameters

d. If a method is returning a value the calling statement must have a variable to store that value


Answer- If a method is returning a value the calling statement must have a variable to store that value


Que-  Which of this method is given parameter via command line arguments?

a. main()

b. recursive() method

c. Any method

d. System defined methods


Answer- main()


Que-  Which of these data types is used to store command line arguments?

a. Array

b. Stack

c. String

d. Integer


Answer- String


Que-  How many arguments can be passed to main()?

a. Infinite

b. Only 1

c. System Dependent

d. None of the mentioned


Answer- Infinite


Que-  Which of these is a correct statement about args in the following line of code? public static void main(String args[])

a. args is a String

b. args is a Character

c. args is an array of String

d. args in an array of Character


Answer- args is an array of String


Que-  Can command line arguments be converted into int automatically if required?

a. Yes

b. No

c. Compiler Dependent

d. Only ASCII characters can be converted


Answer- No


Que-  How do we pass command line argument in Eclipse?

a. Arguments tab

b. Variable tab

c. Cannot pass command line argument in eclipse

d. Environment variable tab


Answer- Arguments tab


Que-  Which class allows parsing of command line arguments?

a. Args

b. JCommander

c. Command Line

d. Input


Answer- JCommander

Previous Post Next Post