Which keyword is used to create an instance of a class in most programming…
2025
Which keyword is used to create an instance of a class in most programming languages?
Answer: B. new — In most programming languages, the keyword 'new' is used to create an instance of a class. It allocates memory for the object and calls the constructor to…
- A.
alloc
- B.
new
- C.
create
- D.
instance
Attempted by 1364 students.
Show answer & explanation
Correct answer: B
In most programming languages, the keyword 'new' is used to create an instance of a class. It allocates memory for the object and calls the constructor to initialize it. This is a standard practice in languages like Java, C#, and JavaScript.
Option A: 'alloc' is used in Objective-C for memory allocation, but it does not initialize the object or call constructors, so it is not the standard keyword for instance creation.
Option B: 'new' is the correct keyword in most languages. It creates a new instance by allocating memory and calling the constructor, making it the standard choice.
Option C: 'create' is not a standard keyword in most languages. While some languages may use it in specific contexts, it is not universally recognized for creating class instances.
Option D: 'instance' is a noun, not a keyword. It refers to the object itself, not the action of creating it, so it cannot be used to instantiate a class.