Which operator can replace a simple if statement in Java?
AThe ?? operator
BThe && operator
CThe ?: operator
DThe || operator
Answer & Solution
Correct answer: C. The ?: operator
The ternary operator ?: can be used in place of a simple if statement.
Keep practising Classes, Encapsulation and Scope
Browse all Classes, Encapsulation and Scope questions for ICSE Class 10, or explore more Computer Applications topics.
Related questions
Match broad forms:
1. ADT: p. Data type
2. Libs: q. Modules
3. Cap: r. SecurityMatch stack flow:
1. Push: p. In scope
2. Pop: q. Exit scope
3. LIFO: r. Stack ruleMatch name scopes:
1. Prefix: p. Qualify
2. Pack: q. Ada Java
3. Space: r. C++ namesMatch Java check:
1. Hide: p. Disallowed
2. Block: q. In braces
3. Top: r. Class modsMatch scope nest:
1. Close: p. Keep env
2. Inner: q. Sub-func
3. Outer: r. Non-localMatch lang spec:
1. CPP: p. 3 keys
2. Java: q. 4 types
3. Swift: r. 5 levelsMatch OOP tension:
1. Design: p. Patterns
2. Subcls: q. Expose
3. Yo-yo: r. Hard bugMatch Java fields:
1. Field: p. In class
2. Local: q. In block
3. Param: r. Signature