Java Mcq1
Java Mcq1
MCQ--------------------------------------
Correct
Question: 1
What among the following is a feature of java?
a.platform dependent
b.procedure oriented
c.middle level language
Correct Answer
ans.d. platform independent
Correct
Question: 2
Who is the father of Java?
a. Guido van Rossum
b. Dennis Ritchie
c. Bjarne Stroustrup
Correct Answer
d. James Gosling
Correct
Question: 3
Does java supports pointers?
a. Yes
Correct Answer
b. No
Correct
Question: 4
JDK stands for:
a. Java Deployment Kit
Correct Answer
ans.b. Java Development Kit
c. Java Developers Kit
d. Java Debugger Kit
Incorrect
Question: 5
Every program in java starts with:
Incorrect Answer
a. main method
Correct Answer
ans.b. class
c. block
d. comment
ans=class
Question: 6
What is the role of public in main method?
a. make the method secured from outside world
b. make the method avaialable for compiler
Correct Answer
ans.c. make the method accessible throughout the project
d. make the method access first in execution
Incorrect
Question: 7
What is the role of static in main method?
a. access the method from another class
Correct Answer
ans.b. JVM can access the method directly
c. main method has String[] args as parameter
Incorrect Answer
d. single main method in a program
ans=b.
Question: 8
What is the role of void in main method?
a. no need to call main method
b. access the method from another class
c. main method can get data from user
Correct Answer
ans.d. main method doesnot return any value
Incorrect
Question: 9
A class name is also called as_______
Correct Answer
ans.a. identifier
b. output statement
c. source code
Incorrect Answer
d. object
ans.a.
Question: 10
Which keyword is used to create object in java?
Incorrect Answer
a. class
b. for
Correct Answer
ans.c. new
d. do
ans.c
Question: 11
Which of the following can be a valid single line comment ?
a. this is a single line comment//
b. //this is a //single line comment
Correct Answer
ans.c. //this is a single line comment
Incorrect Answer
d. /* this is a single line comment*/
ans.c
Question: 12
Which of the case can be compiled successfully?
Incorrect Answer
a. class {}
b. class A{
Correct Answer
ans.c. class A{}
d. class App*{}
ans.c
Question: 13
Java source code is saved with an extension of:
a) .obj
b) .class
Correct Answer
ans.c) .java
d) .cpp
ans.c
Question: 14
Byte code is generated by:
a. JIT compiler
Correct Answer
ans.b. java compiler
c. java interpreter
Incorrect Answer
d. JDK
ans.b
Question: 15
Which of the following is a valid class declaration?
a. class A*{}
b. class $A{}
c. class A$
Correct Answer
ans.d. Both c and b
Correct
Question: 16
How many class files are generated by compiler after
compilation?
a. 1 class file
b. depends on requirement of programmer
Correct Answer
ans.c. depends on the number of classes created in source code
d. depends on number if main method iused in source code
Correct
Question: 17
String is a _ in java
a. keyword
Correct Answer
ans.b. class
c. method
d. variable
Incorrect
Question: 18
Choose the correct statement:
class Apple123
{
System.out.println(“An apple a day keeps the doctor away.”);
public static void main(String[] DJTillu)
{
System.out.println(“Be a coder & give apples to your family.”);
}
}
a. class name is not valid
Incorrect Answer
b. main method declaration is not accepted
Correct Answer
ans.c. Logic should be inside the main method
d. [] should be attached to identifier of parameter in main
ans.c.
Question: 19
What is the output for the given code:
class abc
{
public static void main(String args[])
{
int String = 20;
System.out.println(String);
}
}
a. compile time error
b. run time error
Correct Answer
ans.c. 20
d. String
Incorrect
Question: 20
What is the output for the given code:
class abc
{
public static void main(String args[])
{
String Integer = “2024”;
System.out.println(Integer);
}
}
Incorrect Answer
a. compile time error
b. run time error
c. Integer
Correct Answer
ans.d. 2024