In the following questions segment of code what concept is s

In the following questions, segment of code, what concept is string an example of> String s = \"Hello\"; char c = s.charAt (2); a type a method a variable a program None of the above Each of the following questions may have multiple correct answers. Circle All response that are these questions If x and y are Boolean variables, for what values of x and y does the x = true y = true x = true y = false x = false y = true x = false y = false The expression can never be true, regardless of what values x and f y have If i and j are int variables, for what values of i and j does the expressions (i * j M 6 || i > j) evaluate to false? i = 1, j = 5 i = 5, j =1 i = 3, j = 2 i = 2, j = 3 None of the above assignments of i and j the expressions The following segment provides example (s) of which of the following (foo.length ()

Solution

26.Ans: e

In java string is an object that represents a sequence of characters. Every object is a reference type in java. It provides various string methods. In the above example charAt is a string method to identify the character at the given index.

Here option \'a\' doesn\'t say if it is a data type or reference type. Hence we are not considering that option.


27.Ans: a,b,c

Explanation:

If we consider option \'a\': x=true, y=true : ( !true && true) || true ---> ( false && true) || true ----> false || true ---> true
If we consider option \'b\': x=true, y=false: ( !false && true) || false ---> ( true && true) || false ----> true || false ---> true
If we consider option \'c\': x=false, y=true: ( !true && false) || true ---> ( false && false) || true ----> false || true ---> true
If we consider option \'d\': x=false, y=false : ( !false && false) || false ---> ( true && false) || false ----> false || false ---> false


28.Ans: d

Explanation:

If we consider option \'a\': i=1, j=5 : ( 1*5 < 6 || 1 >5) ---> ( 5 < 6 || 1 > 5) ----> (true || false) ---> true
If we consider option \'b\': i=5, j=1 : ( 5*1 < 6 || 5 >1) ---> ( 5 < 6 || 5 > 1) ----> ( true || true ) ---> true
If we consider option \'c\': i=3, j=2 : ( 3*2 < 6 || 3 >2) ---> ( 6 < 6 || 3 > 2) ----> ( false || true ) ---> true
If we consider option \'d\': i=2, j=3 : ( 2*3 < 6 || 2 >3) ---> ( 6 < 6 || 2 > 3) ----> ( false || false ) ---> false

\'||\' is an or operator. If there is an or operator the final result is always true when either of the expression that is on the left side or right side of that operator is true.

29.Ans: a,c


Explanation for \'a\' being right: we can see asignment operator in the line foo = \"\"; Here we have simple assignment operator \'=\'.

Explanation for \'c\' being right: we can see boolean expression used in if statement i.e., it checks if the foo.length() is less than or equal to 4, if so it evaluates to true else evaluates to false.

Explanation for \'b\' not being right: Java provides three statements for branching and those are break, continue and return.

 In the following questions, segment of code, what concept is string an example of> String s = \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site