In the following questions segment of code what concept is s
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.
