
Vispro Week 1 - OOP concept in DART
Authored by Kasmir Syariati
Computers
University
Used 1+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
33 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is DART?
programming language
programming framework
programming architecture
programming paradigm ✅
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the type of x in the following Dart code?
dynamic
int
Object
num
Answer explanation
When declared with var, Dart infers the type from the first assignment. Here, x becomes int. If you want it to be truly dynamic, you must explicitly declare dynamic.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following correctly explains the difference between final and const in Dart?
final can be set only once at runtime, const is a compile-time constant
const can be reassigned, final cannot
Both are identical
final must always be declared with a value, const does not
Answer explanation
final is initialized once and can hold a runtime value. const must be assigned a compile-time constant.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will this Dart code print?
null
Guest
Compilation error
Empty string
Answer explanation
Since name is nullable and currently null, the null-coalescing operator ?? provides "Guest" as the fallback.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which scenario is the best use case for the late keyword in Dart?
When you want to delay initialization of a non-nullable variable
When you want to make a variable nullable
When you want a compile-time constant
When you want to create a global variable
Answer explanation
late is used when a non-nullable variable cannot be initialized immediately, but you guarantee it will be set before use.
The late keyword in Dart is used to declare a variable or field that will be initialized at a later time, specifically when it is first accessed. This keyword is particularly useful in the context of Dart's sound null safety, as it allows for the declaration of non-nullable variables without requiring immediate initialization.
The primary use case for late is to declare non-nullable variables that cannot be initialized at the point of declaration. Without late, such variables would either need to be marked as nullable (using ?) or initialized immediately, which might not always be feasible.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will this Dart code print?
42
"hello"
Compilation error
dynamic
Answer explanation
A dynamic variable can change its type at runtime. Initially it is an int, then reassigned to a String.
In Dart, the dynamic keyword allows for the declaration of a variable whose type can change at runtime. This means a variable declared with dynamic can hold values of any type, and its type can be reassigned throughout its lifecycle.
Runtime Type Flexibility:
Unlike var (which infers a type at compile-time and then restricts the variable to that type), dynamic truly allows the type to change during program execution.
Reduced Type Safety:
While offering flexibility, using dynamic sacrifices compile-time type checking. This means potential type-related errors might only be discovered at runtime, leading to less robust code compared to using specific types or var with type inference.
Use Cases:
dynamic is typically used when the exact type of a variable is genuinely unknown or when interoperating with external systems (like JSON parsing) where the data structure might be unpredictable.
Best Practice:
In general, it is recommended to use dynamic sparingly and only when necessary due to the reduced type safety. Prefer specific types or var with type inference for better code maintainability and error prevention.
7.
MULTIPLE CHOICE QUESTION
30 sec • 2 pts
What is the purpose of extension methods in Dart?
To allow adding new methods to existing classes without modifying them
To create subclasses dynamically
To override private methods
To replace inheritance
Answer explanation
Extension methods in Dart allow developers to add new functionalities to existing classes without modifying their original source code or using inheritance. This feature is particularly useful for extending the behavior of classes from core libraries or third-party packages that cannot be directly altered.
Extension methods enable the addition of methods, getters, setters, and operators to a class as if they were part of its original definition.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
33 questions
Node JS
Quiz
•
University
35 questions
Cryptography
Quiz
•
University
29 questions
SQL Basics
Quiz
•
University
32 questions
TCP Socket Programming
Quiz
•
University
30 questions
Round_1 (B)| Coding Combat 2.0
Quiz
•
University
30 questions
AS Computer Science
Quiz
•
12th Grade - University
28 questions
PRE/POST TEST - CSS
Quiz
•
University
28 questions
AZ-900 Module 5
Quiz
•
KG - University
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
54 questions
Analyzing Line Graphs & Tables
Quiz
•
4th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade