Question: Java Computer Programming 1. Please provide explanation. 1. Consider the programming problem, A program that prints the square root of a positive integer that is
Java Computer Programming 1. Please provide explanation.
1. Consider the programming problem, A program that prints the square root of a positive integer that is greater than ten". Which among the following data types is most appropriate for the input for the required program?
nboolean
nfloat
nint
ndouble
nchar
2. Consider the programming problem, A program that prints the square root of a positive integer that is greater than ten". What is an appropriate data type that you will assign to the output of the required program?
nByte
nint
nboolean
ndouble
nchar
3. Consider the programming problem, A program that prints the square root of a positive integer that is greater than ten". Should a validation of the input be done by the program?
nYes, an input validation is needed in order to ensure that a given specification in the problem is satisfied.
nNo, an input validation is not relevant as far as satisfying the problem specifications are concerned.
4. Consider the programming problem, A program for determining the velocity of a vehicle in Kilometers Per Hour (KPH) given the distance travelled and the time used in the travel ". Which is a required input for the required program? There may be more than one answer. You have to tick on all correct answers so that you will earn the credit assigned to this exam item.
nTime used in the travel in Hours
nColor of the Vehicle
nLocation of a Gas station
nDistance traveled in Kilometers
nVelocity of the Vehicle in KPH
5. Consider the programming problem, Using the Java programming language, create a program for converting a temperature in degrees Celsius to a temperature in degrees Fahrenheit". Suppose the temperature in degrees Fahrenheit will be represented by the variable fahrenheit and the temperature in degrees Celsius is represented by the variable celsius. Suppose further that the data type of fahrenheit is double and the data type of celsius is double. Which formula will be used in the Java program for the process of conversion? There may be more than one answer. You have to tick on all correct answers so that you will earn the credit assigned to this exam item.
nfahrenheit = 9/5*(celsius)+32
nfahrenheit = 9/5*(celsius) + 32.0
ncelsius = 5/9*(fahrenheit - 32)
nfahrenheit = 1.8*(celsius) + 32
nfahrenheit = 9*(celsius)/5 + 32
6. Which is a valid identifier in the Java programming language? There may be more than one answer. You have to tick on all correct answers so that you will earn the credit assigned to this exam item.
nSession Road
ntwelve percent VAT
n10 pesos
nisMarried
ncompute
7. Based on a real-world perspective, determine the most appropriate data type for the value of an ACRONYM.
nA floating point data type
nString
nchar
nAn integer data type
nboolean
8. An instance of an atomic data type is a single indivisible unit of data. Which is an atomic data type in Java? There may be more than one answer. You have to tick on all correct answers so that you will earn the credit assigned to this exam item.
nint[] (i.e. array of int)
ndouble[] (i.e. array of double)
nboolean
nString
nchar
9. IN PROGRAMMING THEORY, A MIXED-MODE EXPRESSION refers to an expression whose operands have different data types. In such situations, the promotional rule of data types ensures that only one data type is followed. Taking into account the promotional rule of data types in Java, suppose and are variables of type long, and are variables of type float, and are variables of type byte, and are variables of type short, and are variables of type double and and are variables of type int. Which of the following is a valid assignment statement in Java? There may be more than one answer. You have to tick on all correct answers so that you will earn the credit assigned to this exam item.
nD = e/2;
nf = d;
nd = b + i - l
ns = b / j;
ni = s + m;
10. Which expression corresponds to " "
nw/x-y+z
nw/x-(y+z)
ny/z+w+x
n(w+x)/(y-z)
nw/x+(y+z)
11. Which expression corresponds to " "
nw+x+y/z
n(w+x)/(y-z)
nw/x+y/z
nnone of these
nw/x-y+z
12. Analyze (>= && <). What value(s) of n will make the expression true?
n24
nNone of these
n25 and above
n22 and below
n23
13. Analyze (n<23 && n>=24). What value/s of n will make the expression true?
n24
nNone of these
n25 and above
n22 and below
n23
14. SELECTION STATEMENTS are utilized in a program that is required to choose between alternative course of actions by testing certain conditions. Determine the most appropriate selection statement for the situation "The basis of choosing the course of action to take is not based on a boolean expression".
nSwitch - case statement
ncascading if statement
nif - else statement
nif statement
15. SELECTION STATEMENTS are utilized in a program that is required to choose between alternative courses of action by testing certain conditions. Determine the most appropriate selection statement for the situation "The one and only course of action may or may not be executed".
nCascading if statement
nswitch statement
nif statement
nif-else statement
16. In Java programming, an infinite loop occurs when the loop condition is never true.
nFalse
nTrue
17. In Java programming, an infinite loop occurs when the loop condition will never evaluate to true.
nFalse
nTrue
18. How many times will the body of the following loop statement execute? Your answer must be a number in numeral form (i.e. not in words)
19. How many times will the body of the following loop statement execute? Your answer must be a number in numeral form (i.e. not in words)
20. Consider the following loop statement. Assume that the execution of the .() statement will allow the user to enter an integer that is assigned to at run time. Which sample value of will let the flow of execution go back to the body of the loop? There can be more than one answer. You have to tick on all possible answers so that you will earn the points allotted for this exam item.
n0
n-1
n2
n1
n3
n4
n5
21. How many times will the body of the following loop statement execute? Your answer must be a number in numeral form (i.e. not in words)
22. Consider the following Java codes for some methods. What is assigned to 3 points answer by the statement = ( (, ) , );
23. Consider the following Java codes for some methods. What Java expression will yield the same result as the mathematical expression ( = * + (-))? There may be more than one answer. You have to tick on all correct answers so that you will earn the credit assigned to this exam item.
nvalue = add(mul(1,2),sub(3,4));
nvalue = add(mul(2,1),sub(3,4));
nvalue = add(mul(2,1),sub(4,3));
nvalue = add(sub(3,4), mul(1,2));
24. A computer program with a logic error (or logical error) is a syntactically valid program based in the programming language that may yield an incorrect result. Assuming that the methods in Java are defined as shown, is a logical error possible with the use of the expression ( = ((,),(,))) ?
nYes, the expression may result to a value that is not correct because of the the way the div method is implemented.
nNo, the expression will return the correct expected value.
25. Consider the following Java codes for some methods. What Java expression will yield the same result as the mathematical expression ( = (+) * )? There may be more than one answer. You have to tick on all correct answers so that you will earn the credit assigned to this exam item.
nanswer = mul(add(1,2,3))
nanswer = add(mul(1,2),3)
nanswer = mul(add(1,2),3)
nanswer = add(1,mul(2,3))
nanswer = add(1,2) + mul(3)
26. The following outline of a method computes the grade t that a student must earn during the final period if the student wants to have the final grade f given that the student already earned the prelim grade p and that the student already earned midterm grade is m. The following method assumes that the final grade f is determined by getting the average of the prelim grade p, midterm grade m and grade earned during the final period t [i.e. =(++)/]. For the current school term, the director for the Computer Programming 1 course has set a different formula to be followed. The course director prescribed that the final grade(f) is 25% of the prelim grade(p) plus 35% of the midterm grade(m) plus 40% of the grade earned during the final period(t) [i.e. =.+.+.]. What expression may be used to replace the expression for computing t in the body of the given method so that the basis for the computation of t is the formula f=0.25p+0.35m+0.40t instead of =(++)/?
nt = (int) (f - 0.25*p - 0.35*m)/0.40;
nt = (int) (3f - 0.25*p - 0.35*m)/0.40;
nt = (int) (f - 0.25*p + 0.35*m)/0.40;
nt = (0.25*p + 0.35*m -f)/0.40;
nt = (0.25*p - 0.35*m -f)/0.40;
nt = (f - 0.25*p - 0.35*m)/0.40;
nt = (f - 0.25*p + 0.35*m)/0.40;
27. How many primitive data types are there in the Java programming language? Your answer must be a number in numerical form (not in words).
28. What does the acronym GIGO mean in the context of "proactive" programming?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
