What is the difference between if and switch?

1 Answer

Answer :

A: (a) if can compare conditions for all data types whereas, switch can only check integers and characters. (b) all kinds of relations can be checked using if whereas only equality relation can be checked using switch.

Related questions

Description : The ....................... looks only for a match between the value of the expression and one of its case constants. A) if B) match C) switch D) None of the above

Last Answer : C) switch

Description : In java, ............. can only test for equality, where as ............ can evaluate any type of the Boolean expression. A) switch, if B) if, switch C) if, break D) continue, if

Last Answer : A) switch, if

Description : Some of the situations where inline expansion may not work are: A) For functions returning values, if a loop, a switch or goto exists. B) If functions contain static variables and they are re-cursive. C) For functions not returning values, if return statement exist. D) All of the above.

Last Answer : D) All of the above.

Description : …………… are very effective because a mode switch is not required to switch from one thread to another. A) Kernel-level threads B) User-level threads C) Alterable threads D) Application level threads

Last Answer : B) User-level threads

Description : Let the time taken to switch between user mode and kernel mode of execution be T1 while time taken to switch between two user processes be T2. Which of the following is correct? (A) T1 < T2 (B) T1 > T2 (C) T1 = T2 (D) Nothing can be said about the relation between T1 and T2.

Last Answer : (A) T1 < T2

Description : Consider three CPU intensive processes P1, P2, P3 which require 20, 10 and 30 units of time, arrive at times 1, 3 and 7 respectively. Suppose operating system is implementing Shortest Remaining Time first (preemptive scheduling) ... end of Ready queue are not counted). (A) 3 (B) 2 (C) 4 (D) 5

Last Answer : (A) 3

Description : What is the difference between a sequential file and a random file?

Last Answer : Ans: Sequential file access is the method employed in tape drives where the files are access in a sequential manner. So if you have to get a file in the end of the tape you have to start ... Disks and Optical drives, wherever the files is placed it will go to that particular place and retrieve it.

Description : What is the difference between Call by value and Call by reference?

Last Answer : A: Call By Value : When a function is called by value, then the value of the actual parameter is copied to the formal parameter (i.e. a separate copy is made). Any changes made with the ... with the values at that address of the formal parameter affects (changes) the value of the actual parameter.

Description : What is the difference between naming conventions and naming rules?

Last Answer : A: Violating naming rules will result in a syntax error, whereas, violating naming conventions will not result in any error.

Description : What is the difference between keywords and reserved words?

Last Answer : A: Keywords have a special meaning in a language, and are part of the syntax. Reserved words are words that cannot be used as identifiers (variables, functions, etc.), because they are reserved by the ... goto is a reserved word but not a keyword (as a consequence, you cannot use it at all)

Description : What is the difference between linear and binary search?

Last Answer : A: Linear search does not require the array to be sorted, whereas, binary search requires that the array be sorted. Linear search checks for the search item in a linear fashion from the beginning cell till the end, ... tell what is control variable in your loop. So if your loop is for(int i = 1; i

Description : What is the difference between selection sort and bubble sort?

Last Answer : A: In selection sort, successive rounds are executed to select the element which is required to be placed in their sorted position, whereas, in bubble sort, every consecutive pairs of elements are compared ... element at every pass, whereas, in bubble sort we get the largest element in every pass.

Description : What is the difference between break and continue?

Last Answer : A: break keyword stops the complete loop and takes the control out of the loop, whereas, the continue keyword just stops the current iteration and takes the control to the next iteration.

Description : What is the difference between length() and length?

Last Answer : A: length() function is used to find the number of characters present in a String, whereas, length keyword is used to find the number if cells in an array.

Description : What is the difference between function overloading and function overriding?

Last Answer : A: In function overloading only the function name is same but function signature (list of parameters) is different, whereas, in function overriding both the function name as well as function ... is an example of static polymorphism, whereas, function overriding is an example of dynamic polymorphism.

Description : What is the difference between recursion and iteration?

Last Answer : A: Recursion is usually slower than iteration due to overhead of maintaining stack, whereas, Iteration does not use stack so it's faster than recursion. Recursion uses more memory than ... whereas, Iteration consume less memory. Recursion makes code smaller, whereas, Iteration makes code longer.

Description : What is the difference between do-while and while?

Last Answer : A: do-while lop is exit controlled (i.e. condition is checked at the exit) and runs at least once even if the condition is false whereas, while loop is entry controlled (i.e. condition is checked at the entry) and does not run even once if the condition is false.

Description : What is the difference between for and while?

Last Answer : A: The difference lies in the way they are commonly used. for loop is commonly used when the number of iterations are known whereas, while loop is commonly used when the number of iterations are not known.

Description : What is the difference between casting and coercion?

Last Answer : A: Type Casting refers to Explicit type conversion i.e. When the conversion takes place with the programmer’s intervention, whereas, Coercion refers to Implicit type conversion i.e. When the conversion takes place on its own without the programmer’s intervention.

Description : What is the difference between throws and throw?

Last Answer : A: Using throws keyword, we can give system defined error message if any error occurs, while using throw keyword, we can force an exception and give user-defined error messages.

Description : What is the difference between print() and println() methods?

Last Answer : A: The print() functions prints a line and the control remains on the same line, whereas, the println() function prints a line and the control moves on to the next line.

Description : Methods can be overloaded with a difference only in the type of the return value .. A) Not supported B) False C) True D) None of the above

Last Answer : B) False

Description : _____ produces the relation that has attributes of R1 and R2 (A) Cartesian product (B) Difference (C) Intersection (D) Product

Last Answer : A) Cartesian product

Description : The essential difference between traps and interrupts is (A) traps are asynchronous and interrupts are synchronous with the program (B) traps are synchronous and interrupts are asynchronous with the program ( ... synchronous and interrupts are asynchronous with the I/O devices. (D) None of these.

Last Answer : (B) traps are synchronous and interrupts are asynchronous with the program

Description : A tree with n vertices is called graceful, if its vertices can be labelled with integers 1, 2, ...,n such that the absolute value of the difference of the labels of adjacent vertices are all different. Which of the following trees are ... (B) (b) and (c) (C) (a) and (c) (D) (a), (b) and (c)

Last Answer : Answer: D

Description : ECL is the fastest of all logic families. High Speed in ECL is possible because transistors are used in difference amplifier configuration, in which they are never driven into ............... (1) Race condition (2) Saturation (3) Delay (4) High impedance

Last Answer : Answer: 2  Explanation: Emitter-coupled logic (ECL) is the fastest of all logic families and therefore is used in applications where very high speed is essential. High speeds have become ... configuration, in which they are never driven into saturation and thereby the storage time is eliminated.