Home

C++ Online Question

What is a correct syntax to output "Hello World" in C++? (A) System.out.println("Hello World"); (B) print ("Hello World"); (C) Console.WriteLine("Hello World"); (D) cout << "Hello World";

C++ is an alias of C# (A) True (B) False

How do you insert COMMENTS in C++ code? (A) /* This is a comment (B) // This is a comment (C) # This is a comment

Which data type is used to create a variable that should store text? (A) myString (B) Txt (C) String (D) string

How do you create a variable with the numeric value 5? (A) num x = 5 (B) int x = 5; (C) x = 5; (D) double x = 5;

How do you create a variable with the floating number 2.8? (A) double x = 2.8; (B) int x = 2.8; (C) byte x = 2.8 (D) x = 2.8;

Which method can be used to find the length of a string? (A) getSize() (B) getLength() (C) len() (D) length()

Which operator is used to add together two values? (A) The + sign (B) The & sign (C) The * sign

The value of a string variable can be surrounded by single quotes. (A) False (B) True

Which header file lets us work with input and output objects? (A) #include <stream> (B) #include <iostream> (C) #include <inputstr> (D) #include <iosstring>

C++ Online Question

Which operator can be used to compare two values? (A) = (B) == (C) <> (D) ><

To declare an array in C++, define the variable type with: (A) () (B) [] (C) {}

Array indexes start with: (A) 1 (B) 0

How do you create a function in C++? (A) functionName. (B) (functionName) (C) functionName[] (D) functionName()

How do you call a function in C++? (A) functionName(); (B) (functionName); (C) functionName; (D) functionName[];

Which keyword is used to create a class in C++? (A) class (B) className (C) class() (D) MyClass

What is the correct way to create an object called myObj of MyClass? (A) MyClass myObj; (B) class MyClass = new myObj(); (C) new myObj = MyClass(); (D) class myObj = new MyClass();

In C++, it is possible to inherit attributes and methods from one class to another. (A) False (B) True

Which method can be used to find the highest value of x and y? (A) maximum(x,y) (B) largest(x,y) (C) max(x,y) (D) maxNum(x,y)

Which operator is used to multiply numbers? (A) # (B) x (C) * (D) %

C++ Online Question

How do you create a reference variable of an existing variable? (A) With the ref word (B) With the * operator (C) With the & operator (D) With the REF word

How do you start writing an if statement in C++? (A) if (x > y) (B) if x > y then: (C) if x > y:

How do you start writing a while loop in C++? (A) x > y while { (B) while (x > y) (C) while x > y { (D) while x > y:

Which keyword is used to return a value inside a method? (A) return (B) get (C) break (D) void

Which statement is used to stop a loop? (A) exit (B) stop (C) break (D) return