Notepad

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Can we directly compile codes from notepad? - An integer literal with decimal point.

-Yes, Because we can call Java compiler from Which of the following is a valid identifier?
notepad
- None of these
What is the correct statement to set JavaC path in
command line? Which of the following is not a Java comment?

- C:\Program Files\Java\jdk1.6.0_23\bin -Declaration Comments

Which of the following is true about syntax errors: Which of the following is not a java keyword?

- All of these -name

Why do we need to set the path for JavaC in Which of the following is not an escape sequence?
command line?
-None of these
- It is part of the compilation process
Which of the following is not a valid variable
What is the correct statement to run Java program in declaration in Java?
command line?
-float x = 2.0D;
-java HelloWorld
Which of the following a valid Java identifier?
What is the correct statement to compile Java
-All of these
program in command line?
Which of the following is not a valid Float value?
-javac HelloWorld.java
-1.23
What is the extension name of a Java Source code?
Which of the following is not Java Literal?
-java
-None of the above
Which of the following we are not allowed to write java
source code? What did java generates after compiling the java
source code?
-None of these
-Executable file
What will happen if we compile the statement below?
~System.out.println(“Hello World!”) Which of the following is not the feature of java?

- There will be a syntax error after compilation. -Static

JVM is responsible for Which of the following is true about Runtime errors:

- Compiling source code - Runtime errors occur during run-time.

What was the initial name for the Java programming The Java feature, "write once, run anywhere", is
language? termed as

-Oak - Platform independent

Which of the following is not a primitive data type? -Portable

-String The feature of Java which makes it possible to


execute several tasks simultaneously.
What is floating-point literal?
- Multithreaded
When was the officially released of Java? Which of the following is a valid nexDouble() return
value?
-1995
-double value
What is the input for Java Compiler?
What is the length of the array: int[] intArray = { 1, 2,
- Byte Code 3, 5, 6, 7 };
Can we directly compile codes from NetBeans? -6
- Yes, because we can call Java compiler from
What is the output of the code snippet below:
NetBeans
            int[] intArray = { 1, 2, 3, 5, 6, 7 };
Which of the following is a valid nextByte() return             for(int x = intArray.length-1; x>=0; x--)
value? {System.out.print(intArray[x]);}

-3 -765321

What type of value does the nextLine() returns? Which of the following is a valid multidimensional
array?
- Line
-All of these
What will happen if you use JOptionPane.
showInputDialog statement in your program? What is the output of the code snippet below:
            int[] intArray = new int[10];
- The program will display an input dialog box that
allows the user to input text and returns the for(int x = 0; x<intArray.length; x++)
{System.out.print(intArray[x]);}
correct type value.
-0123456789
Which is not a repetition control structure?
Which of the following correctly accesses the sixth
-Switch element stored in an array of 10 elements?
Which statement will check if x is equal to y? -stringArray[5];
- None of these From the array int[] intArray = { 1, 2, 3, 5, 6, 7 };, what
is the value of intArray[3]? 
What will be the value of x after you execute this
statement
-5
int z=0; for(int x=0; x<10; x++) for(int y=0; y<x; y++)
z*=(x*y); Which of the following declares an array of int named
- None of these intArray?

Which of the following has the correct form for an if -int[] intArray;
statement?
What is the maximum index of the array: int[] intArray
- if (boolean_expression) = { 1, 2, 3, 5, 6, 7 };
What will be the output if you execute this code?
-5
do{System.out.println("Hello World!");}while(true);
-print "Hello World" infinitely What is the index number of the last element of an
array with 30 elements?
Which of the following is a valid statement to accept
String input? -29

-String str = scan.nextString(); What will be the output if you execute this code?
do{System.out.println("Hello World!");}while(false);
-Do nothing Which of the following is a valid nextInt() return value?

Which of the following is a valid statement to accept -1010


int input? Let us assume that we have declared scan
Which of the following does not return numeric value?
as Scanner.
-None of these
-short num = scan.nextInt();
What is the return value of this method: int test()
What is the return value of this method: public void
{return 1;} ?
sum(){int x=1;} ?
-1
-void
What is the output of the code snippet below:
Which is not a decision control structure?
            void main(){test(“11”);test(“1”);}
-if else-if else
            void test(String x){System.out.print(x + x);}
what will be the output if you execute this code? -222
int x=1;
Which of the following is a valid method name:
switch(x){
case 1: -None of these

                System.out.print(“1”); Which statement will check if x is less than y?


case 2:
-if (x<y);
                System.out.print(“1”);
case 3: What is the name of this method: int test(){return 1;} ?

                System.out.print(“1”); - test


default:
Which of the following shows a valid Overloading
                System.out.print(“1”); method? 
}
- None of the choices
-display 1
What is the output of the code snippet below:
Which of the following method reads input from the
            int[] intArray = new int[10];
user and return String value?
for(int x = 0; x<intArray.length; x++)
-nextString() {System.out.print(intArray[x]);}
-  012356789
What is the output of the code snippet below: void
main(){test();test();} void test(){System.out.print(“1”);} What do you call a variable that belong to the whole
-1 class?

Which of the following shows Overloading method? - Class Method

-All of these Which of the following will do implicit cast? 

What will be the value of x after executing this code - All of these

for(int x=0; x<=10; x++) {} is run? Which of the following show casting object?
-10
- All of the choices
It is a template for creating an object? Which of the following method is allowed to be
overriden?
- Object Oriented
- None of these
Which of the following creates an instance of a class?
What keyword is used to perform class inheritance?
- All of the choices
- extends
What will be the value of x if we execute this: String s
= "25"; int x = Integer.parseInt(s); ? Which of the following class declaration is not allowed
to be inherited?
- The code is not valid.
- None of these
It is the method of hiding certain elements of the
implementation of a certain class? It is the ability of an object to have many forms?

- Encapsulation - Polymorphism

What do you call a blueprint of an object? What do you call a class that inherits a class?

- Class - Subclass

What is the result if we execute this: “a” instanceof What is the index number of the last element of an
String; ? array with 20 elements?

-False -19

What is the result if we execute this: “a”.equals(“a”);? what will be the output if you execute this code?
int x=2;
-  true
switch(x){
Which of the following is true about Interface?
case 1:
- It defines the signatures of a set of methods             System.out.print(“1”);
without the body case 2:
Which of the following is the correct way to define an             System.out.print(“1”);
interface? case 3:
- public interface [InterfaceName] {}             System.out.print(“1”);
default:
Which of the following is the correct way to use an
interface?             System.out.print(“1”);
}
- public class Person use [InterfaceName] {}
- display 1
Which of the following is the correct way to call the
constructor of the parent class? Which of the following is a valid editor for java source
code?
- this.call()
- All of the choices
Which of the following class declaration is not allowed
to be instantiated? From the array int[] intArray = { 1, 2, 3, 5, 6, 7 };, what
is the value of intArray[2]?
- class Person{}
-2
Which of the following is true about constructor?

- Constructors have the same name as the class

What will be the output if you execute this code:


int a[] = new int[1];
System.out.println(a[1]);
- It will display nothing.

What is the function of JVM?

- Generating bytecode

Which of the following scenarios where an exception


may occur?

- All of the choices

It used to read values from class variables?

-  Instance Variable

It is used to access the instance variables shadowed


by the parameters.

- method

You might also like