You are on page 1of 17

Quiz#1

JVM is responsible for


Select one:
a. Compiling source code
b. Interpreting bytecode Correct
c. None of the Above
d. Reading bytecode
e. Generating bytecode

The feature of Java which makes it possible to execute several tasks simultaneously.
Select one:
a. Code Security
b. Multithreaded Correct
c. None of the Above
d. Robust
e. Platform independent

The Java feature, "write once, run anywhere", is termed as


Select one:
a. High Performance
b. None of the Above
c. Object Oriented
d. Platform independent Correct
e. Robust

What did java generates after compiling the java source code?
Select one:
a. Image file
b. None of the Above
c. Byte Code Correct
d. Executable file
e. Class Code

Which of the following we are not allowed to write java source code?
Select one:
a. Notepad
b. BlueJ
c. NetBeans
d. eclipse
e. None of the Above Correct

What is the extension name of a Java Source code?


Select one:
a. javac
b. j
c. java Correct
d. class

e. None of the Above


What is the input for Java Compiler?
Select one:
a. None of the Above
b. Code
c. Native Code
d. Source Code Correct
e. Byte Code

Which of the following is not the feature of java?


Select one:
a. Code Security
b. Robust
c. Platform independent
d. None of the Above
e. Static Correct

When was the officially released of Java?


Select one:
a. 1996
b. None of the Above
c. 1992
d. 1995 Correct
e. 1991

What was the initial name for the Java programming language?
Select one:
a. NetBeans
b. C
c. Java
d. Oak Correct
e. None of the Above

Quiz#2

Can we directly compile codes from NetBeans?


Select one:
a. No, we can only write codes in NetBeans
b. Both A and C are correct.
c. Yes, because we can call Java compiler from NetBeans Correct
d. It depends, if there is a compiler embedded in NetBeans.

Which of the following is true about Runtime errors:


Select one:
a. Runtime errors occur when there is a design flaw in your program
b. Runtime errors occur after compilation.
c. Runtime errors occur during run-time. Correct
d. All of the above.
e. None of the Above
Can we directly compile codes from notepad?
Select one:
a. Yes, Because we can call Java compiler from notepad
b. No, W e can only write codes in Notepad Correct
c. Both A and C are correct.
d. It depends, if there is a compiler embedded in Notepad.

Which of the following we are not allowed to write java source code?
Select one:
a. None of the Above Correct
b. NetBeans
c. BlueJ
d. Notepad
e. eclipse

What will happen if we compile the statement below?


~System.out.println(“Hello W orld!”)
Select one:
a. There will be a runtime error after compilation.
b. There will be no error after compilation.
c. There will be a logical error after compilation.
d. There will be a syntax error after compilation. Correct
e. None of the Above

What is the correct statement to run Java program in command line?


Select one:
a. javac HelloW orld
b. java HelloW orld.java
c. None of the Above
d. javac HelloW orld.java
e. java HelloWorld Correct

What is the correct statement to compile Java program in command line?


Select one:
a. java HelloW orld
b. javac HelloWorld.java Correct
c. java HelloW orld.java
d. javac HelloW orld

Which of the following is true about syntax errors:


Select one:
a. You will have syntax errors if you misspell the Java command.
b. Incorrect capitalization leads to syntax error.
c. Syntax errors are usually typing errors.
d. All of the above. Correct
e. None of the Above
Why do we need to set the path for JavaC in command line?
Select one:
a. It is part of the compilation process
b. To make JavaC available or accessible in command line. Correct
c. To resolve runtime error
d. None of the Above
e. To resolve syntax error

What is the correct statement to set JavaC path in command line?


Select one:
a. set path
b. C:\Program Files\Java\jdk1.6.0_23\bin Correct
c. set path
d.
e. None of the Above
f. path C:\Program Files\Java\jdk1.6.0_23\bin
g. All of the above

Quiz# 3

Which of the following is not a primitive data type?


Select one:
a. short
b. long
c. byte
d. none of the above
e. String Correct

Which of the following is not a java keyword?


Select one:
a. name Correct
b. None of the above
c. goto
d. else
e. if

Which of the following is not a Java comment?


Select one:
a. None of the above
b. Documentation Comments
c. Declaration Comments Correct
d. Single Line Comments
e. Multi-Line Comments

Which of the following is not a valid Float value?


Select one:
a. 3.4028235E+38F
b. none of the above Correct
c. 1.2345E+3
d. 1.23
e. 12345678910F
Which of the following is not a valid variable declaration in Java?
Select one:
a. int x
b. float x
c. short x;
d. int x;
e. 1; Correct
f. None of the above
g. 2.0D;

Which of the following is not Java Literal?


Select one:
a. None of the above Correct
b. Integer value
c. Boolean value
d. Character value
e. Float value

Which of the following a valid Java identifier?


Select one:
a. all of the above
b. _id
c. id
d. $id
e. id_1 Correct

Which of the following is not an escape sequence?


Select one:
a. \t
b. \b
c. \f
d. none of the above Correct

Which of the following is a valid identifier?


Select one:
a. static
b. public
c. true
d. None of the above
e. name Correct

What is floating-point literal?


Select one:
a. By default it is double type.
b. It could be double or float value.
c. All of the above Correct
d. An integer literal with decimal point.
e. Can be express in scientific notation.
Quiz # 5

Which of the following is a valid statement to accept String input?


Select one:
a. None of the above
b. string str = scan.nextShort();
c. String num = scan.nextText();
d. String str = JOptionPane.showInputDialog(""); Correct
e. String str = scan.nextString();

Which of the following is a valid nextByte() return value?


Select one:
a. short value
b. int value
c. 3 Correct
d. None of the above
e. 128

Which of the following is a valid statement to accept int input? Let us assume that we have declared scan
as Scanner.
Select one:
a. None of the above Correct
b. short num = scan.nextInt();
c. short num = scan.nextShort();
d. int num = scan.getInt();
e. int num = scan.nextLong();

What type of value does the nextLine() returns?


Select one:
a. double
b. String Correct
c. long
d. Line
e. None of the above

What will happen if you use JOptionPane.showMessageDialog statement in your program?


Select one:
a. The program will display an input dialog box that allows the user to input text and returns String value.
b. The program will display message dialog box. Correct
c. None of the above
d. The program will display message dialog box returns String value.
e. The program will display an input dialog box that allows the user to input text and returns the correct
type value.
Which of the following method reads input from the user and return String value?
Select one:
a. All of the above
b. nextValue()
c. nextText()
d. nextLine() Correct
e. nextString()

Which of the following is a valid nextInt() return value?


Select one:
a. 1010 Correct
b. None of the above
c. long value
d. 3.1416
e. floating-point literal

Which of the following does not return numeric value?


Select one:
a. nextDouble()
b. nextLong()
c. nextShort()
d. None of the above Correct
e. nextInt()

What will happen if you use JOptionPane. showInputDialog statement in your program?
Select one:
a. The program will display message dialog box returns String value.
b. The program will display an input dialog box that allows the user to input text and returns the correct
type value.
c. The program will display message dialog box.
d. The program will display an input dialog box that allows the user to input text and returns
String value. Correct
e. None of the above

Which of the following is a valid nexDouble() return value?


Select one:
a. All of the above Correct
b. 12.0
c. double value
d. floating-point literal
e. 3.1416
Quiz # 6

What will be the output if you execute this code?


do{System.out.println("Hello W orld!");}while(false);

Select one:
a. print "Hello W orld" infinitely
b. Do nothing
c. None of the above.
d. The code will not run because of syntax error
e. print "Hello World" Correct

Which is not a decision control structure?


Select one:
a. switch
b. if
c. if else
d. if else-if else
e. None of the above Correct

What will be the value of x after you execute this statement


int z=0; for(int x=0; x<10; x++) for(int y=0; y<x; y++) z*=(x*y);
Select one:
a. 128
b. 512
c. None of the above Correct
d. 1
e. 236

Which statement will check if x is equal to y?

Select one:
a. none of the above Correct
b. if (y>y)
c. if (x<>y)
d. if (x>y)
e. if (x!<y)

what will be the output if you execute this code?


int x=1;
switch(x){
case 1:
System.out.print(“1”);
case 2:
System.out.print(“1”);
case 3:
System.out.print(“1”);
default:
System.out.print(“1”);
}
Select one:
a. display 1
b. display 1111 Correct
c. display 1234
d. None of the above}
e. display nothing

What will be the output if you execute this code?


do{System.out.println("Hello W orld!");}while(true);

Select one:
a. The code will not run because of syntax error
b. None of the above.
c. print "Hello W orld"
d. print "Hello World" infinitely Correct
e. Do nothing

What will be the value of x after executing this code


for(int x=0; x<=10; x++) {} is run?

Select one:
a. 11 Correct
b. 10
c. 1
d. none of the above
e. 0

Which statement will check if x is less than y?

Select one:
a. if (x>y)?:
b. none of the above
c. if (x>y)
d. if (x<y); Correct
e. if (x<>y)

Which is not a repetition control structure?


Select one:
a. while
b. for
c. None of the choices
d. do while
e. switch Correct

Which of the following has the correct form for an if statement?


Select one:
a. if boolean_expression
b. boolean_expression
c. if boolean_expression
d. if (boolean_expression) Correct
e. none of the above
Quiz # 7

Which of the following correctly accesses the sixth element stored in an array of 10 elements?
Select one:
a. intArray[6]; Incorrect
b. intArray[10];
c. intArray[7];
d. None of the above
e. stringArray[5];

Which of the following is a valid multidimensional array?


Select one:
a. int[][] intArray;
b. int[][][][] intArray;
c. All of the above Correct
d. int[][][] intArray;
e. int intArray[][][];

Which of the following correctly accesses the sixth element stored in an array of 10 elements?
Select one:
a. intArray[7];
b. None of the above
c. stringArray[5]; Correct
d. intArray[6];
e. intArray[10];

What is the index number of the last element of an array with 30 elements?
Select one:
a. 30
b. 31
c. None of the above
d. 29 Correct
e. 0

What is the output of the code snippet below:


int[] intArray = { 1, 2, 3, 5, 6, 7 };
for(int x = intArray.length-1; x>=0; x--){System.out.print(intArray[x]);}
Select one:
a. 12356
b. none of the choices
c. The given code is not valid
d. 123567
e. 765321 Correct
What is the output of the code snippet below:
int[] intArray = new int[10];
for(int x = 0; x<intArray.length; x++){System.out.print(intArray[x]);}
Select one:
a. 012356789
b. 1235678910
c. 0000000000 Correct
d. none of the choices
e. The given code is not valid

Which of the following declares an array of int named intArray?


Select one:
a. All of the above Correct
b. int intArray[][];
c. int[][] intArray;
d. int intArray[];
e. int[] intArray;

What is the maximum index of the array: int[] intArray = { 1, 2, 3, 5, 6, 7 };


Select one:
a. 4
b. None of the choices
c. 7
d. 5 Correct
e. 6

What is the length of the array: int[] intArray = { 1, 2, 3, 5, 6, 7 };


Select one:
a. none of the choices
b. 6 Correct
c. 7
d. 5
e. 4

From the array int[] intArray = { 1, 2, 3, 5, 6, 7 };, what is the value of intArray[3]?
Select one:
a. 5 Correct
b. 7
c. None of the choices
d. 6
e. 4
Quiz # 8

What is the output of the code snippet below:


void main(){test(“11”);test(“1”);}
void test(String x){System.out.print(x + x);}
Select one:
a. 111111 Correct111
b. 6
c. 222
d. None of the choices

Which of the following shows a valid Overloading method?


Select one:
a. void test(){} void test(){}
b. void test(int x){} void test(int y){}
c. All of the choices
d. none of the choices Correct
e. void test(char x, int y){} void test(int x, char y){}

What is the return value of this method: public void sum(){int x=1;} ?
Select one:
a. x
b. void Correct
c. sum
d. 1
e. none of the choices

Which of the following shows Overloading method?


Select one:
a. All of the above
b. None of the above
c. void test(int x){} void test(int y){}
d. void test(int x){} void test(double x){} Correct
e. void test(){} void test(){}

What is the output of the code snippet below:


void main(){
test(1.0);
test(1);}
void test(double x){
System.out.print(x); }
void test(int x){
System.out.print(x);}
Select one:
a. None of the choices
b. 11
c. 1.01.0
d. 1.0
e. 1.01 Correct
What is the return value of this method: int test(){return 1;} ?
Select one:
a. test
b. return 1
c. All of the choices
d. int
e. 1 Correct

What is the return type of this method: int test(){return 1;} ?


Select one:
a. 1
b. test()
c. int Correct
d. void
e. None of the above

What is the output of the code snippet below: void main(){test();test();} void test(){System.out.print(“1”);}
Select one:
a. 11 Correct
b. None of the choices
c. 2
d. 1
e. 3

What is the name of this method: int test(){return 1;} ?


Select one:
a. 7
b. None of the choices
c. int
d. test Correct
e. 6

Which of the following is a valid method name:


Select one:
a. none of the choices
b. compute Correct
c. final
d. compute grade
e. int
Quiz # 9

Which of the following creates an instance of a class?


Select one:
a. String str = new String();
b. Test t = new Test();
c. String str = new String();
d. Object obj = new Object();
e. All of the choices Correct

What is the result if we execute this: “a”.equals(“a”);?


Select one:
a. true Correct
b. None of the above
c. The code is not valid
d. “a”
e. false

What do you call a variable that belong to the whole class?


Select one:
a. Object Variable
b. Static Variable
c. None of the above
d. Class Method
e. Class Variable Correct

It is a template for creating an object?


Select one:
a. None of the above
b. Encapsulation
c. Method
d. Object Oriented
e. Class Correct

What is the result if we execute this: “a” instanceof String; ?


Select one:
a. None of the above
b. true Correct
c. “a”
d. false
e. The code is not valid

What do you call a blueprint of an object?


Select one:
a. Method
b. Object
c. Constructor
d. Class Correct
e. None of the above
What will be the value of x if we execute this: String s = "25"; int x = Integer.parseInt(s); ?
Select one:
a. int 25 Correct
b. 0
c. None of the above
d. String 25
e. The code is not valid.

Which of the following show casting object?


Select one:
a. All of the choices Correct
b. (className) object;
c. SuperClass sc = new SuperClass(); SubClass sbc = new SubClass(); sbc = (SubClass) sc;
d. Employee emp = new Employee(); VicePresident veep = new VicePresident(); veep =
(VicePresident)emp;

It is the method of hiding certain elements of the implementation of a certain class?


Select one:
a. None of the above
b. Encapsulation Correct
c. Object
d. Object Oriented
e. Class

Which of the following will do implicit cast?


Select one:
a. None of the above
b. All of the above
c. String x = “0”; int y = x;
d. short x=1; int y = x; Correct
e. Object obj = new Object();

Quiz # 10

Which of the following class declaration is not allowed to be instantiated?


Select one:
a. public final class Person {}
b. public abstract class Person {} Correct
c. public class Person {}
d. class Person{}
e. None of the above
Which of the following method is allowed to be overriden?
Select one:
a. public void setName(){}
b. public static void setName(){}
c. public final void setName(){} Correct
d. None of the above
e. public no_override void setName(){}

Which of the following is the correct way to call the constructor of the parent class?
Select one:
a. this()
b. super() Correct
c. this.call()
d. super.call()

It is the ability of an object to have many forms?


Select one:
a. Polymorphism Correct
b. Inheritance
c. None of the above
d. Abstraction
e. Interface

Which of the following is the correct way to use an interface?


Select one:
a. public class Person implements [InterfaceName] {} Correct
b. public class Person use [InterfaceName] {}
c. public class Person extends [InterfaceName] {}
d. public class Person apply [InterfaceName] {}
e. None of the above

Which of the following class declaration is not allowed to be inherited?


Select one:
a. public final class Person {} Correct
b. class Person{}
c. public abstract class Person {}
d. None of the above
e. public class Person {}

Which of the following is the correct way to define an interface?


Select one:
a. public [InterfaceName] {}
b. public class interface [InterfaceName] {}
c. public interface [InterfaceName] {} Correct
d. interface: [InterfaceName]
What keyword is used to perform class inheritance?
Select one:
a. None of the above
b. extends Correct
c. inherits
d. derives
e. implements

What do you call a class that inherits a class?


Select one:
a. Superclass
b. Subclass Correct
c. Class
d. Parent class
e. None of the above

Which of the following is true about Interface?


Select one:
a. All of the above Correct
b. It defines a standard and public way of specifying the behavior of classes
c. It is a special kind of block containing method signatures only
d. It defines the signatures of a set of methods without the body
e. It is use to model multiple inheritance which allows a class to have more than one superclass.