C++ and Java Programming Fundamentals
Test your knowledge of fundamental programming concepts in C++ and Java, including operators, data types, pointers, arrays, and language-specific features.
Questions
What is the difference between Synchronous and Asynchronous updates?
- In synchronous processing, the program waits: control returns to the program only when the task has been completed
- In asynchronous processing, the program does not wait: the system returns control after merely logging the request for execution
- In asynchronous processing, the program waits: control returns to the program only when the task has been completed
- In synchronous processing, the program does not wait: the system returns control after merely logging the request for execution
Which of the following lines will compile without warning or error
- float f=1.3;
- int i=10;
- char c="a";
- byte b=257;
- boolean b=null;
A byte can be of what size
- -128 to 127
- (-2 power 8 )-1 to 2 power 8
- -255 to 256
- depends on the particular implementation of the Java Virtual machine
Which of the following are keywords or reserved words in Java?
- if
- then
- goto
- while
What will happen if you try to compile and run the following code? public class Q { public static void main(String argv[]){ int anar[]=new int[5]; System.out.println(anar[0]); } }
- Error: anar is referenced before it is initialized
- null
- 0
- 5
Which of the following most closely describes a bitset collection?
- A class that contains groups of unique sequences of bits
- A method for flipping individual bits in instance of a primitive type
- An array of boolean primitives that indicate zeros or ones
- A collection for storing bits as on-off information, like a vector of bits
Is C++ case sensitive?
- No
- Case sensitivity is compiler-determined
- Yes
- Don't Know
What does the code "cout<<(0==0);" print?
- 0
- 1
- Compiler error: Lvalue required
- Don't Know
If the program completes executing successfully, what value should the function main() return?
- 0
- 1
- void
- Don't Know
In which header file is isalpha() declared?
- conio.h
- stdio.h
- ctype.h
- stdlib.h
What will happen when the following code is run: int x; while(x<100) { cout<<x; x++; }
- The computer will output "0123...99"
- The computer will output "0123...100"
- The output is undefined
- Don't know
What does the following code output? void afunction(int *x) { x=new int; *x=12; } int main() { int v=10; afunction(&v); cout<<v; }
- Outputs 12
- Outputs 10
- Outputs the address of v
- Compile error
What is the outcome of the line of code "cout<<abs(-16.5);"?
- 16
- 17
- 16.5
- Error
What value will "strcmp("Astring", "Astring");" return?
- A positive value
- A negative value
- Zero
- Compile Error
Evaluate !(1&&1||1&&0)
- Error
- True
- False
- Can't Say
What header file is needed for the function exit()?
- stdlib.h
- conio.h
- dos.h
- ctype.h