Question

1). The result of Java expression 5*7>3*(5+2) && 3*5-4<6 is ____ a. 35>35&&9<6 b. true &&...

1). The result of Java expression 5*7>3*(5+2) && 3*5-4<6 is ____
a. 35>35&&9<6
b. true && false
c. false
d. False

(2). You save text files containing Java language source code using the file extension___
a. .java
b. .class
c. .txt
d. .src
  
(3). Which of the following is not a primitive data type in the Java programming language?
a. boolean
b. byte
c. int
d. Point

(4). Given the Java statement int[][] vari = new int[5][7]; the value of vari[4].length is
a. 4
b. 5
c. 6
d. 7

(5). To use any of the prewritten classes besides those in the java.lang package, you must___
a. use the entire path with the class name
b. import the class
c. import the package of which the class you are using is a part
d. use any of these methods

(6). Assuming x = 25, y = -1, z = 32, the expression !( x / 2 == 12 ) || ( z*3 == 96 ); gives ___
a. False
b. true
c. false
d. True

(7). Given String str1 = “Java is useful!”; Statement System.out.println(str1.charAt(14)); displays ___
a. 14
b. !
c. l
d. error message
  
(8). Given a static method public static void swap(int x, int y){ int temp = x; x = y; y = temp; }, if x=3, y=5; then the value of x and y after the method call swap(x,y) is_____;
a. 3, 5
b. 5, 3
c. 3, 3
d. 5, 5

(9). A class header must contain___
a. an access modifier
b. the keyword class
c. the keyword static
d. the keyword public

(10). Which of the following expression refers the last element of array arr?
a. arr[last]
b. arr[arr.length]
c. arr[arr.length – 1]
d. arr[end]

(11). Given Java statement int[] arr = new int[10]; the last element is___
a. 10
b. arr[10]
c. arr[9]
d. arr[0]

(12). Given Java statement Random rand = new Random( ); which of the following Java statements will
generate a random integer between 2 and 5 is
a. rand.nextInt(4)+2;
b. rand.nextInt(5) +2;
c. rand.nextInt(6) +2;
d. rand.nextInt(2,5);

(13). You can declare two variables with the same name as long as___
a. they appear within the same block
b. they are assigned different values
c. they are of different types
d. their scopes do not overlap

(14). Given Java statement int[] arr = new int[10]; the statement System.out.println(arr) gives__
a. 10
b. 9
c. compiler error
d. The memory location where array arr is stored.

(15). If str is a String, ______ gives the total number of characters in the string str.
a. str.length
b. str.length()
c. str
d. str[]

0 0
Add a comment Improve this question Transcribed image text
Answer #1


ANSWER:-

1) A) 5*7>3*(5+2) && 3*5-4<6

   3*7 = 35

   3*(5+2) = 21

therefore, 35 > 21 = true

3*5-4 == 11

therefore, 11 < 6 = true

   true && true = true

SO, ANSWER is true.

2) .java

3) Point is not a primitive data type. It is a class

4) ANSWER is 7. Because vari[4].length gives no of columns in that row.

5) c. import the package of which the class you are using is a part

6) !( x / 2 == 12 ) || ( z*3 == 96 );

   Explanation:- x = 25

       x/2 = 25/2 = 12

     (x/2 == 12) = true

    !(x/2 == 12) = false

z = 32

   (96 == 96) = true

    !( x / 2 == 12 ) || ( z*3 == 96 ) = false || true = true

ANSWER is true.

7) ANSWER is !. because string length is 15. and indices are in range 0 to 14. and 14th index is !.

8) 5, 3

9) b) the keyword static

10) c. arr[arr.length – 1]

11) arr[9]

12) rand.nextInt(4)+2; rand.nextInt(n) generates random numbers in range 0 to n-1

13) their scopes do not overlap

14) The memory location where array arr is stored.

15) str.length()

NOTE:- If you have any doubts,please comment below.Please give positive rating.THUMBS UP.

          THANK YOU!!!!

Add a comment
Know the answer?
Add Answer to:
1). The result of Java expression 5*7>3*(5+2) && 3*5-4<6 is ____ a. 35>35&&9<6 b. true &&...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 10. Which of the following correcthy milites elements each with value 0? super Bass to com...

    10. Which of the following correcthy milites elements each with value 0? super Bass to com I inttl superBass { 0, 0, 0, 0, 0 ); int(1 superBass = new int [5] inttl superBass = new int (5) for (int i = 0; i < super Bass.length superBass ) = 0; +) (A) (B) I only II only I and II only I and III only I. II, and III (D) (E) 17. Consider the following Java program public class...

  • Consider the following code segment. int[]arr={1, 2, 3, 4, 5, 6, 7, 8}; for(int k=3; k<arr.length-1;...

    Consider the following code segment. int[]arr={1, 2, 3, 4, 5, 6, 7, 8}; for(int k=3; k<arr.length-1; R++ arr[k]-arr[k+1]; What are the contents of arr as a result of executing the code segment? a. {1, 2, 3, 5, 6, 7, 8, 8) b. {2, 2, 4, 5, 6, 7, 8, 8} C. {2, 4, 6, 5, 6, 7, 8,8} d. {4, 2, 4, 4, 6, 7, 8, 8) e. {6, 6, 4, 5, 6, 7, 8, 8} int) arr={7, 2.5, 3.0,...

  • Question 1 An array is NOT: A - Made up of different data types. B - Subscripted by integers. C -...

    Question 1 An array is NOT: A - Made up of different data types. B - Subscripted by integers. C - A consecutive group of memory chunks. D - None of the choices. Question 2 How many times is the body of the loop executed? int i=1; while(true) { cout << i; if(++i==5) break; } A - Forever B - 4 C - 5 D - 6 E - 0 Question 3 What is wrong with the following piece of...

  • JAVA getting the following errors: Project4.java:93: error: ']' expected arr[index] = newVal; // LEAVE THIS HERE....

    JAVA getting the following errors: Project4.java:93: error: ']' expected arr[index] = newVal; // LEAVE THIS HERE. DO NOT REMOVE ^ Project4.java:93: error: ';' expected arr[index] = newVal; // LEAVE THIS HERE. DO NOT REMOVE ^ Project4.java:93: error: <identifier> expected arr[index] = newVal; // LEAVE THIS HERE. DO NOT REMOVE ^ Project4.java:94: error: illegal start of type return true; ^ Project4.java:98: error: class, interface, or enum expected static int bSearch(int[] a, int count, int key) ^ Project4.java:101: error: class, interface, or...

  • I need to write a program in java that reads a text file with a list...

    I need to write a program in java that reads a text file with a list of numbers and sorts them from least to greatest. This is the starter file. import java.util.*; import java.io.*; public class Lab3 { static final int INITIAL_CAPACITY = 5; public static void main( String args[] ) throws Exception { // ALWAYS TEST FOR REQUIRED INPUT FILE NAME ON THE COMMAND LINE if (args.length < 1 ) { System.out.println("\nusage: C:\\> java Lab3 L3input.txt\n"); System.exit(0); } //...

  • A. What is the value of the following statement? Math.pow(6, 3) B. For the following code:...

    A. What is the value of the following statement? Math.pow(6, 3) B. For the following code: String sentence; String str; sentence = "First exam is on Monday."; str = sentence.replace('s', '$'); C. What type of input does the following program require, and in what order must the input be provided? import java.util.*; public class Strange { static Scanner console = new Scanner(System.in); public static void main(String[] arg) { int x; int y; String name; x = console.nextInt(); name = console.nextLine();...

  • The code snippet below is an example of pass by reference. We also provide a sample...

    The code snippet below is an example of pass by reference. We also provide a sample method setZeroAt, which sets 0 at a position i in the array, to illustrate pass by reference. public class Sample { public static void setZeroAt(int [] arr, int i){ arr[i] = 0; } public static void main(String[] args) { Scanner input = new Scanner(System.in); int sample[] = {1, 2, 3}; setZeroAt(sample, 1); //Now sample looks like {1, 0, 3} } } Write a Java...

  • JAVA programming 9.9 Ch 9, Part 2: ArrayList Searching import java.util.ArrayList; public class ArrayListSet {    ...

    JAVA programming 9.9 Ch 9, Part 2: ArrayList Searching import java.util.ArrayList; public class ArrayListSet {     /**      * Searches through the ArrayList arr, from the first index to the last, returning an ArrayList      * containing all the indexes of Strings in arr that match String s. For this method, two Strings,      * p and q, match when p.equals(q) returns true or if both of the compared references are null.      *      * @param s The string...

  • 1) Consider the following Java program: 1 public class HelloWorld { 2     // My first program!...

    1) Consider the following Java program: 1 public class HelloWorld { 2     // My first program! 3     public static void main(String[] args) { 4         System.out.println("Hello, World!"); 5     } 6 } What is on line 1? a. a variable declaration b. a statement c. a method (subroutine) definition d. a comment e. a class definition 2) Which one of the following does NOT describe an array? a. It can be used in a for-each loop. b. It has a numbered sequence...

  • please evaluate the following code. this is JAVA a. class Car { public int i =...

    please evaluate the following code. this is JAVA a. class Car { public int i = 3; public Car(int i) { this.i = i; } } ... Car x = new Car(7), y = new Car(5); x = y; y.i = 9; System.out.println(x.i); b. class Driver { public static void main(String[] args) { int[] x = {5, 2, 3, 6, 5}; int n = x.length; for (int j = n-2; j > 0; j--) x[j] = x[j-1]; for (int j...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT