What is the value of the result variable after executing

Assignment Help JAVA Programming
Reference no: EM133161265

Object Oriented Concepts

Question 1. Which of the following commands allows you to create the file named Hello.class containing the bytes of code that will have to be loaded into memory during its execution:

a) java Hello
b) java Hello.java
c) javac Hello.java
d) javac Hello.html

Question 2. Which of the following statements will display the chain Hello World?

a) System.out.printf( "%2s", "Hello" "Word" );
b) System.out.printf( "%s %s %s", "Hello", "World" );
c) System.out.printf( "%s%s%s", "Hello, World" );
d) System.out.printf("s% s% %s", "Hello" "le" "World" );

Question 3. What is the result of this program? public class OpIncr
{
public static void main(String[] args)
{ int i, j, n ;
i = 0 ; n = i++ ;
System.out.println ("A : i = " + i + " n = " + n ) ;

i = 10 ; n = ++ i ;
System.out.println ("B : i = " + i + " n = " + n ) ;

i = 20 ; j = 5 ; n = i++ * ++ j ;
System.out.println ("C : i = " + i + " j = " + j + " n = " + n ) ;
} }

a) A : i = 0 n = 1 B
: i = 11 n = 11
C : i = 21 j = 6 n = 120

b) A : i = 1 n = 0
B : i = 11 n = 11
C : i = 21 j = 6 n = 120

c) A : i = 1 n = 0 B : i = 0 n = 11
C : i = 20 j = 6 n = 120

d) A: i = 1 n = 1
B : i = 11 n = 11
C : i = 21 j = 6 n = 140

Question 4. What is the value of the result variable after executing the following Java statements?

int a, b, c, d, result; a = 4;
b = 12;
c = 37;
d = 51;
result = d % a * c + a % b + a;

a) 119
b) 51
c) 127
d) 59

Question 5. Which of the following is not a syntax error?

a) Forgetting to initialize a local variable in a method before using it.
b) Using only one = symbol instead of two in an if statement.
c) Adding a semi-colon (;) at the end of the first line of an if statement.
d) Forgetting to put the left and right parentheses in an if statement.

Question 6. Every Java application is made up of at least on of the following:

a) public method
b) data members
c) Defining a public class
d) an imported class

Question 7. From the following choices, which is a name that is entirely qualified and that allows us to access the methods of a Scanner object?

a) Scanner
b) java.Scanner
c) util.Scanner
d) java.util.Scanner

Question 8. What is the result of the following Java Code?
int temp; temp = 200;
if ( temp > 90 )
System.out.println( "This coffee is too hot." );

if ( temp < 70 )
System.out.println( "This coffee is too cold." );

if ( temp == 80 )
System.out.println( "This coffee is perfect!" );

a) This coffee is too hot.
b) This coffee is too cold.
c) This coffee is perfect!
d) Non of the above.

Question 9. What is the result of the following Java code?

int temp; temp = 180;
while ( temp != 80 )
{
if ( temp > 90 )
{
System.out.print( "This coffee is too hot! " ); temp = temp - ( temp > 150 ? 100 : 20 );
}
else
{
if ( temp < 70 )
{
System.out.print(
"This coffee is too cold! ");
temp = temp + (temp < 50 ? 30 : 20);
}
}
}

if ( temp == 80 )
System.out.println( "This coffee is perfect!" );

a) This coffee is too cold! This coffee is perfect!
b) This coffee is too hot! This coffee is perfect!
c) This coffee is perfect!
d) None of the above.

Question 10. Which of the following will count down from 10 to 1 correctly?

a) for ( int j = 10; j <= 1; j++ )
b) for ( int j = 1; j <= 10; j++ )
c) for ( int j = 10; j > 1; j-- )
d) for ( int j = 10; j >= 1; j--)

Question 11. Which of the following statements is true with respect to a do...while statement?

a) The body of the do...while loop will be executed only if the result is true.
b) The body of the do...while loop will only be executed once.
c) The body of the do...while loop will always be executed at least once.
d) None of these answers

Question 12. In the following segment of code, what value of the q variable will yield the display of the word kiwi?
switch( q )
{ case 1:
System.out.println( "apple" ); break;
case 2:
System.out.println( "orange" ); break;
case 3:
System.out.println( "banana" ); break;
case 4:
System.out.println( "pear" ); case 5:
System.out.println( "grapes" ); default:
System.out.println( "kiwi" );
}
a) 2
b) any value equal to or greater than 4
c) 1
d) 3

Question 13. Consider the following segment of code.

if ( sex == 1 )
{ if ( age >= 65 )
++seniorFemales;
} // end if

Which of the following is equivalent to the segment of code above?

a) if ( sexe == 1 || age >= 65 ) ++seniorFemales;
b) if ( sexe == 1 && age >= 65 ) ++seniorFemales;
c) if ( sexe == 1 AND age >= 65 ) ++seniorFemales;
d) if ( sexe == 1 OR age >= 65 ) ++seniorFemales;

Question 14. Which of the following statements will compile without an error? Assume that the method is called upon using the following instruction and that the application contains only one getNumber method.
int num = getNumber(1,10);

a) 1
b) 2
c) 3
d) 4

Question 15. The following bloc of code is part of a more complex application. What will be the result of the following bloc of code?

public class Test
{
public void add (int b)
{
int Nums [ ] = new int [6]; for(int a=0; a < 7; a++)
{
Nums[a] = a*2; System.out.print(Nums[a]);
}
}
}

a) 0 2 4 6 8
b) 0 2 4 6 8 10 12
c) 0 2 4 6 8 16 32 64
d) An arrayIndexOutofBound exception is generated

Question 16. In the following Java instruction:

int Nombres[ ] = {5,10, 15, 20, 25};

Which of the following definition of method will be executed in response to a ModifierNumbers(Number[4]) instruction;?

a) public void ModifyNumbers(void)
b) public void ModifyNumbers(int b[ ] )
c) public void ModifyNumbers(int b)
d) public void ModifyNumbers(int b[4])

Question 17. The application on which you are working requires a randomly generated four digit number that will serve to identify the user. You decide to implement a method that will return the four digit ID. The call that activates this method is the following:
String UserID = getID(10);

Which of the following methods will return the ID as required?

a) 1
b) 2
c) 3
d) 4

Question 18. Which of the following statements about Break is false?

a) Break allows you to qui a loop structure prematurely and continue the execution after the loop

b) A break command allows you to quit immediately a while, for, do...while or switch structure in which we find the break.

c) The break command, when executed in a while, for or do...while structure, does not execute the commands that follow it and returns to the start of the structure to continue with a new iteration of the loop.

d) The common use of the break command is to quit a loop immediately and before its end, as well as to exit a switch structure.

Question 19. What will be the final value of c after the execution of the following segment of code?

int c = 8; c++;
++c;
c %= 5;

a) 0
b) 1
c) 3
d) None of these answers

Question 20. Considering that the file entitled Cercle.java contains the java code for a java application, the execution of this application will always start on the line of code.

a) static void main(String args[ ])
b) import java.*;
c) public class Cercle {
d) Cercle C = new Cercle( );

Question 21. What is a package?

a) A big package !
b) An object.
c) A list of folder and subfolders containing Java classes.
d) A list of java classes containing subfolders.

Question 22. Find the mistake in the following code

1 Scanner sc = new Scanner(System.in);
2 System.out.println("Please input an integer : ");
3 double d = sc.nextInt();
4 System.out.println("You have inserted the number : " + d);
a) No errors, the code will execute normally
b) We use nextInt() instead of nextDouble().
c) There is a ; missing somewhere
d) The use of new is not necessary to define sc.

Question 23. What must you never forget to do when you use a class that does not belong to the java.lang package?

a) Nothing at all as the necessary classes will be automatically added to the compilation of the program
b) To import the necessary class(es)
c) To configure the eclipse development environment or any other.
d) To add comments to the program

Question 24. The following question is based on this segement of code: public class afficherText
{
public static void main ( String args[ ] )
{
System.out.print("Welcome "); System.out.print("to the "); System.out.println("conference center. Please"); System.out.println("register at the reception.");
}
}

After the compilation and execution of this application, what will be the result produced by this segment of code?

1)

Welcome

Conference center. Please Register at the reception.

3)

Welcome to the conference center. Please register at the reception.

2)

4)

Welcome to the conference center. Please

Welcome to the conference

Register at the reception

Center. Please register

 

At the reception.

a) 1
b) 2
c) 3
d) 4

Question 25. A static type variable is:
a) a "class variable ". If the instance variable of this class is modified, all of the object instances are automatically modified. Therefore, the variable does not depend of the currant instance, but of the class.
b) a variable must be defined in every class instance
c) is used only in main(String args[ ])

d) is accessible only by methods that are declared static
Attachment:- Object Oriented Concepts.rar

Reference no: EM133161265

Questions Cloud

Progress and barriers : Convey your progress and/or barriers that have had an impact on your academic progress
Trading of government securities : The money related base is controlled during the lead of ?nancial approach by a money service or the national bank. These establishments change the money related
Controlling ?nancing costs and setting save necessities : Regularly, a national bank can likewise impact banking exercises by controlling ?nancing costs and setting save necessities (how much cash banks should keep ava
Advice for aspiring human resource managers : Imagine or think of yourself as a Human Resource Manager, then answer the questions.
What is the value of the result variable after executing : What is the value of the result variable after executing the following Java statements and What is the result of the given Java Code
Explain the differences between a group and team : Explain the differences between a group and team. Then, discuss the stages of group and team development as it applies to groups in your workplace. Be sure to f
Find the future worth using the present worth : Consider the following investment cash flows with the interest rate of 7% compounded annually. Find the future worth using the present worth
What is surprising about the employee life cycle : Question: What is surprising about the employee life cycle to you?
How do contingencies affect leading : How do contingencies affect leading? Give examples to illustrate your answer.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write an application that uses an array

Write an application that uses an Array to store 10 messages of type String. You can load this data structure with 10 messages of your choosing.

  Teaching software componentization

Describe one way in which one could apply Java graphics in education. Provide one example of such use to support your response and analyze at least three commands that you would use in order to draw a bar chart. Provide a rationale for your respons..

  Program that mimic operations of the inside of an elevator

Unit Title Fundamentals of Operating Systems and Java Programming - Write an algorithm and a program that mimic the operations of the inside of an elevator

  Define a two-dimension array

1. Define a two-dimension array with 10 rows and 2 columns.

  Assessment taskyour task is to develop a java application

assessment taskyour task is to develop a java application that allows the user to read travel booking data from a text

  Various ways of exception handling

Various ways of exception handling

  Java programming arrays

Write a Java application program that takes in user input from keyboard and calculate semester grade based on the scores. In this assignment, you are going to rewrite the program, instead of taking keyboard input, you will use dialog box to prompt..

  Write a java application using netbeans ide

Write a Java application using NetBeans Integrated Development Environment (IDE) that calculates the total annual compensation of a salesperson. Consider the following factors:A salesperson will earn a fixed salary of .A salesperson will also rece..

  Days alive calculator

The context for this assignment (all parts) is a ‘Days Alive Calculator' - a small desktop application for calculating the number of days someone has been alive based on the date of birth and a second date, which may be today's date or some other ..

  Write a program that reads an unspecified number

Write a program that reads an unspecified number of integers, determines how many positive and negative values have been read.

  Determine whether or not there exists sequence of currencies

Suppose that we are given n currencies. Give an efficient algorithm to determine whether or not there exists a sequence of currencies.

  Write all the instructions in one java file

Write all the instructions in ONE Java file. DO NOT write a Java file for each part. Clearly explain the output (don't just display a number).

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd