Saturday, February 27, 2021

Computer Programming 2

ITE 6104 Computer Programming 2

Why do we need to set the path for JavaC in command line?

To make JavaC available or accessible in command line

Which of the following is true about Runtime errors:

Runtime errors occur during run-time.

What is the input for Java Compiler?

Source Code

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

Platform independent

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

java HelloWorld

Can we directly compile codes from NetBeans?

Yes, because we can call Java compiler from NetBeans

When was the officially released of Java?

1995

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

C:\Program Files\Java\jdk1.6.0_23\bin

Which of the following is true about syntax errors:

All of these

The feature of Java which makes it possible to execute several tasks simultaneously.

Multithreaded

Which of the following is not a valid variable declaration in Java?

float x = 2.0D;

Which of the following is not Java Literal?

None of the above

Which of the following is not an escape sequence?

None of these

Which of the following is not a Java comment?

Declaration Comments

Which of the following a valid Java identifier?

id_1

Which of the following is not a valid Float value?

None of these

What is floating-point literal?

All of these

Which of the following is not a primitive data type?

String

Which of the following is not a java keyword?

name

Which of the following is a valid identifier?

name

Which of the following is not the feature of java?

Static

Which of the following we are not allowed to write java source code?

None of these

Can we directly compile codes from notepad?

No, We can only write codes in Notepad

Why do we need to set the path for JavaC in command line?

To make JavaC available or accessible in command line.

What will happen if we compile the statement below? ~System.out.println(“Hello World!”)

There will be a syntax error after compilation.

What is the extension name of a Java Source code?

java

What did java generates after compiling the java source code?

Byte Code

JVM is responsible for

Interpreting bytecode

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

javac HelloWorld.java

What was the initial name for the Java programming language?

Oak

Which of the following is not a valid variable declaration in Java?

float x = 2.0D;

Which of the following is a valid statement to accept int input? Let us assume that we have declared scan as Scanner.

None of these

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

5

Which of the following is a valid method name:

compute

What is the output of the code snippet below:

void main(){test(“11”);test(“1”);}

void test(String x){System.out.print(x + x);}

111111

What is the index number of the last element of an array with 30 elements?

29

Which statement will check if x is equal to y?

None of these

Which of the following shows Overloading method?

void test(int x){} void test(double x){}

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

6

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]);}

0000000000

What will be the output if you execute this code? do{System.out.println("Hello World!");}while(false);

print "Hello World"

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

The program will display message dialog box.

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);}

1.01

What is the return value of this method: public void sum(){int x=1;} ?

void

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

All of these

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

The program will display an input dialog box that allows the user to input text and returns String value.

What type of value does the nextLine() returns?

String

Which of the following is a valid multidimensional array?

All of these

Which statement will check if x is less than y?

if (x<y);

What is the output of the code snippet below: void main(){test();test();} void test(){System.out.print(“1”);}

11

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

1

Which of the following does not return numeric value?

None of these

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

3

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

All of these

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

test

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

String str = JOptionPane.showInputDialog("");

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

int

From the array int[] intArray = { 1, 2, 3, 5, 6, 7 };, what is the value of intArray[3]?

5

Which is not a decision control structure?

None of these

Which of the following shows a valid Overloading method?

None of these

What will be the output if you execute this code? do{System.out.println("Hello World!");}while(true);

print "Hello World" infinitely

Which of the following correctly accesses the sixth element stored in an array of 10 elements?

stringArray[5];

Which of the following method reads input from the user and return String value?

nextLine()

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

if (boolean_expression)

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”); }

display 1111

 

 

 

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

1010

What will be the value of x after executing this code for(int x=0; x<=10; x++) {} is run?

11

What will be the value of x after you execute this statement int z=0; for(int x=0; x

None of these

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]);}

765321

Which is not a repetition control structure?

switch

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

public final class Person {}

What will be the output if you execute this code:

int a[] = new int[1];

System.out.println(a[1]);

It will produce an exception.

Which of the following is the correct syntax to define a method?

package ;

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

6

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

Encapsulation

what will be the output if you execute this code?

int x=2;

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”); }

display 111

 

 

 

Which of the following is a valid statement to accept int input? Let us assume that we have declared scan as Scanner.

int num = scan.nextInt();

What will be the value of x after executing this code for(int x=0; x<=11; x++) {} is run?

12

Which of the following is true about constructor?

All of the choices

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

true

What keyword is used to perform class inheritance?

extends

From the array int[] intArray = { 1, 2, 3, 5, 6, 7 };, what is the value of intArray[2]?

3

It used to read values from class variables?

Accessor

Which of the following scenarios where an exception may occur?

All of the choices

Which of the following is true about syntax errors:

All of the above.

Which of the following is a valid editor for java source code?

All of the choices

Which of the following shows Overloading method?

void test(int x){} void test(double x){}

It is used to access the instance variables shadowed by the parameters.

this

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);

 

None of the Choice

What is the index number of the last element of an array with 20 elements?

19

What do you call a blueprint of an object?

Class

It is a template for creating an object?

Class

Which of the following will do implicit cast?

short x=1; int y = x;

What will be the value of x if we execute this: String s = "25"; int x = Integer.parseInt(s); ?

int 25

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

Class Variable

Which of the following show casting object?

All of the choices

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

true

Which of the following creates an instance of a class?

All of the choices

Which of the following method is allowed to be overriden?

public final void setName(){}

What do you call a class that inherits a class?

Subclass

Which of the following is the correct way to call the constructor of the parent class?

super()

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

public abstract class Person {}

Which of the following is true about Interface?

All of these

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

public class Person implements [InterfaceName] {}

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

Polymorphism



No comments:

Post a Comment