Objective-c Coding Test

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Jaksiboy
J
Jaksiboy
Community Contributor
Quizzes Created: 832 | Total Attempts: 12,227,871
| Attempts: 964 | Questions: 10
Please wait...
Question 1 / 10
0 %
0/100
Score 0/100
1. What is wrong with this sequence of code? sum = 100; int sum;

Explanation

In this sequence of code, the variable "sum" is being assigned a value of 100 before it is declared as an integer using the "int" keyword. In programming, variables must be declared before they can be used. Therefore, the correct answer is "A variable must be declared before it can be used."

Submit
Please wait...
About This Quiz
Objective-c Coding Test - Quiz

Objective-C is a general-purpose, object-oriented programming language derived from the C programming language. It was the main programming language used by Apple for their OS X and iOS... see moreoperating systems prior to the introduction of SWIFT. After all that history, I am sure you will want to know more about this programming language. Find out how much you know by attempting this quiz. see less

2. What is the file extension name used for Objective-C code?

Explanation

The file extension name used for Objective-C code is .m. This extension is commonly used in Objective-C programming to indicate that the file contains code written in the Objective-C language. Other file extensions mentioned in the options, such as .cpp, .pl, and .c, are used for different programming languages like C++, Perl, and C. Therefore, .m is the correct answer for the file extension name used for Objective-C code.

Submit
3. What does the leading + sign at the start of a method indicate?

Explanation

The leading + sign at the start of a method indicates that it is a class method. Class methods are methods that are associated with the class itself rather than with an instance of the class. They can be called on the class directly, without creating an instance of the class.

Submit
4. Which is an example of an invalid variable name?

Explanation

The variable name "x123$" is an example of an invalid variable name because it starts with a special character ($) which is not allowed in variable names. In most programming languages, variable names can only start with a letter or an underscore, not with a special character.

Submit
5. What is the value of z after executing this sequence (check indentation)? int x = 100, y = 50, z = -1; if ( x + y > 50)    if ( x + y < 100)       z = 0; else    z = 1;

Explanation

The value of z is 1 because the first if statement evaluates to true since 100 + 50 is greater than 50. Then, the nested if statement also evaluates to true since 100 + 50 is less than 100. Therefore, z is assigned a value of 0.

Submit
6. Given int a = 10, b = 20, c; b *= a + 5; What is the resulting value of b?

Explanation

The resulting value of b is 300. The expression "b *= a + 5" is equivalent to "b = b * (a + 5)". Since a is 10, the expression becomes "b = b * (10 + 5)". Since b is initially 20, the expression further simplifies to "b = 20 * 15", which evaluates to b = 300.

Submit
7. What is the value of s after executing this loop: int i = 0, s = 0; while (i < 5)    s += ++i;

Explanation

The value of 's' is 15 after executing the loop because the loop iterates 5 times. In each iteration, 'i' is incremented by 1 using the pre-increment operator (++i), and then added to 's'. So, in the first iteration, 'i' becomes 1 and 's' becomes 1. In the second iteration, 'i' becomes 2 and 's' becomes 3. This process continues until the fifth iteration, where 'i' becomes 5 and 's' becomes 15.

Submit
8. What should you do If you want to return an object back to the caller of your method and you want to mark the object for a later release?

Explanation

If you want to return an object back to the caller of your method and mark it for a later release, you should autorelease it before returning. Autoreleasing an object means that it will be automatically released at a later time, allowing the caller to use the object without worrying about memory management. This is useful when you want to pass ownership of the object to the caller, but still want to ensure that it will be released when it is no longer needed.

Submit
9. Which value is not equivalent to the others?

Explanation

The value 0xE5 is not equivalent to the others because it is represented in hexadecimal notation, while the other values are represented in decimal or octal notation.

Submit
10. What is a local variable that has no default initial value and does not retain its value through method calls?

Explanation

An auto variable is a local variable that has no default initial value and does not retain its value through method calls. Unlike global and static variables, which have default initial values and can retain their values across method calls, an auto variable is only accessible within the scope of the method in which it is declared and must be explicitly assigned a value before it can be used. Therefore, the correct answer is an auto variable.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 21, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Dec 14, 2017
    Quiz Created by
    Jaksiboy
Cancel
  • All
    All (10)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
What is wrong with this sequence of code? sum = 100; int sum;
What is the file extension name used for Objective-C code?
What does the leading + sign at the start of a method indicate?
Which is an example of an invalid variable name?
What is the value of z after executing this sequence (check...
Given ...
What is the value of s after executing this loop: ...
What should you do If you want to return an object back to the caller...
Which value is not equivalent to the others?
What is a local variable that has no default initial value and...
Alert!

Advertisement