CS 492 Exam

¡Supera tus tareas y exámenes ahora con Quizwiz!

Invalid, because data has a type of List<int>

Because of Dart's type system, specify whether the following code is valid or invalid, and why. var data = [4, 8, 12]; data[0] = '2';

SQLite

Both the Android and iOS platforms use which relational database system?

class Freighter extends Spaceship {int capacity;}

Consider the following class definition below. class Spaceship {String name;} Which of the following classes is a subclass of Spaceship?

Valid

Consider the following function implementation. void transport() {print("Transporting!");} Identify whether it is valid, or the reason why it is invalid.

Ship ship = Ship('Serenity');

Consider the following simple class definition. class Ship {String name;Ship(this.name);} Which of the following properly instantiates a Ship object?

True

Dart uses a static type system with type inference, which often lets us omit type annotations.

as a tree of Widgets

Flutter models application components...

Declare the dependencies in pubspec.yml and run `flutter pub get`

How do we add external libraries to our project, so that they are available to use in our code?

False

Programs have a starting point or "main entry point." Dart enables top-level code, defined in a source file outside of the body of any function, as its starting point (similar to Python, Ruby or JavaScript).

True

String literals in Dart may use single or double tick marks.

pub

The Dart SDK includes the dart compiler and other tools. The tool for installing packages in Dart, similar to npm (JavaScript), gem (Ruby) or pip (Python), is:

False

The Dart convention is to use tabs for indentation.

Widgets

The Flutter SDK consists of components that are, in general...

The Flutter SDK depends on the underlying platform-specific SDKs

The Flutter SDK enables developers to create mobile applications that run on both Android and iOS. So why must we also have either the Android or iOS SDKs installed as well?

responsive design

The ability to design and build applications with user interfaces that work on devices with different screens and orientations is known as...

the model-view-controller pattern

The iOS SDK and Android SDKs tend to encourage code architecture that resembles...

They're both right, but the first example relies on type inference: because the expression on the right has a type of List<WordPair>, we do not have to explicitly use the data type annotation on the left.

There is something significantly different about the code in Part 1 of our project vs the code in Part 2. For example, in Part 1, we might see: final _suggestions = <WordPair>[]; But in Part 2, the same line of code is shown as: final List<WordPair> _suggestions = <WordPair>[]; Is there an error in the code? Which one is right? What does the difference indicate to us about the Dart language?

flutter create [directory]

To create a new flutter project, we can us the flutter command-line tool and run...

import

To import a library in Dart, we use the following keyword:

The ability to reload the code of a live running app without restarting or losing app state

What is Flutter's "Stateful Hot Reload" feature?

A library or a collection of pre-written code that we can readily import and use in our own project

What is a package?

A collection of tools and software libraries for building cross-platform mobile applications

What is the Flutter SDK?

List<String>

What is the data type of the following literal? ['Fee', 'Fi', 'Fo', 'Fum']

CocoaPods

What tool do iOS developers use for managing dependencies?

Java, Objective-C

Which of the following languages are good to know for mobile application development, even though they are no longer the primary language used, since so many mobile apps were built with them?

A simulator/emulator is a software replica of a physical device, upon which our app can run

A running mobile application expects that it is running on an actual, physical device. What role does a simulator/emulator have in the workflow of mobile application development?

excessive cascading indentation, aka "pyramid of doom"

Consider the following Dart and Flutter code, extracted from the "Create Your First Flutter App" project. Widget build(BuildContext context) {return Scaffold(appBar: AppBar(title: Text('Startup Name Generator'),actions: <Widget>[IconButton(icon: Icon(Icons.list),onPressed: _pushSaved),]),body: _buildSuggestions(),);}

Extract the actions argument into a well-named function

Consider the following Dart and Flutter code, extracted from the "Create Your First Flutter App" project. Widget build(BuildContext context) {return Scaffold(appBar: AppBar(title: Text('Startup Name Generator'),actions: <Widget>[IconButton(icon: Icon(Icons.list),onPressed: _pushSaved),]),body: _buildSuggestions(),);} Which of the following descriptions below might best help to improve this code?

String body = r?.body;

Consider the following class definition and code snippet. class Request {final String body;Request({this.body});}Request r;// ...String body = r.body; Assume that r is tragically null. As such, the last statement above will raise a an exception: NoSuchMethodError: The getter 'body' was called on null. Which of the following revisions to the last statement above would prevent this runtime error?

New Engine instances will have a weight that is null. The constructor should ensure all instance variables have a valid value.

Consider the following class definition: class Engine {int price;String model;int weight;Engine(int price, String model) {this.price = price;this.model = model;}} Which of the following describes the relevant runtime safety issue, and how to resolve it?

The name of the function should be improved Type annotations for parameters should be used A return type should be declared

Consider the following function implementation. assemble(x, y) {return x + y;} The function is valid, but has a few flaws. What are the flaws? (select multiple)

Invalid, because the return type does not match the type of the return value

Consider the following function implementation. int transport() {return '42';} Identify whether it is valid, or the reason why it is invalid.

Valid, but should ideally use a return type

Consider the following function implementation. transport() {return 42;} Identify whether it is valid, or the reason why it is invalid.

foo(4, 8); foo(4);foo();

Consider the following function implementation. void foo([int x, int y]) {//...} Which of the following is a valid invocation of the function? (select multiple)

foo(x: 100, z: 10);foo();

Consider the following function implementation. void foo({int x = 4, int y = 8, int z = 15}) {print(x);print(y);print(z);} Which of the following is a valid invocation of the function and shows the corresponding console output? (select multiple)

foo(y: 8, x: 4); foo(x: 4, y: 8);

Consider the following function implementation. void foo({int x, int y}) {//...} Which of the following is a valid invocation of the function? (select multiple)

scores.firstWhere( (n) => n % 3 == 0 );

Consider the following list. final scores = [4, 8, 15, 16, 23, 42]; Which of the following returns the first number in the list that is divisible by 3?

Ship(this.name); Ship(String name) : this.name = name;

Consider the following simple class definition. class Ship {String name;Ship(String name) {this.name = name;}} Which of the following constructors are equivalent to the one above? (select multiple)

Ship({this.name = "Unnamed"});

Consider the following simple class definition. class Ship {String name;Ship({name = "Unnamed"}) {this.name = name;}} Which of the following constructors are equivalent to the one above?

Function foo has a parameter that is a function type.

Consider the following snippet of code. void main() {foo(bar);}void bar() {// ...} Assuming that an implementation of foo is defined, select the single most truthful statement below.

In the first statement, the type annotation communicates what value name will store. Using var would be too vague. In the second statement, we see the value assigned to the variable, so the type annotation is redundant.

Consider the following statements. String name;var initialHeight = 100; Why is it appropriate to include the type annotation in the first statement, but omit the type annotation in the second statement? (select two)

dart main.dart 42, dart main.dart foo, dart main.dart

Consider the simple Dart program below. void main(List<String> arguments) {print(arguments[1]);} Given that the source file is named main.dart, which of the following executions of the program results in an error? (select multiple)

double get volume {return this.height * this.width * this.depth;}

Convert the following method to a getter. Assume that the body of the method is valid. double volume() {return this.height * this.width * this.depth;}

XML files and Android Studio's Design View

Flutter has a particular approach for building UIs as code. What approach does the native Android SDK use?

Xcode storyboards

For the iOS SDK, what do developers use to build their application UIs?

Spaceship.megaFast()

Given a class Spaceship with a named parameterless constructor megaFast, which of the following properly invokes this named constructor? Correct!

dart space_adventure.dart

Given a dart file space_adventure.dart, you can compile and run the program via:

for (var s in ships) {s.launch();}

Given that Spaceship objects have a launch method, and you have a List named ships containing 100 Spaceship objects, consider the following snippet of code. for (int i = 0; i < 100; ++i) {ships[i].launch();} Which of the following is equivalent to the snippet above?

ships.forEach((s) => s.launch());

Given that Spaceship objects have a launch method, and you have a List named ships containing 100 Spaceship objects, consider the following snippet of code. for (int i = 0; i < 100; ++i) {ships[i].launch();} Which of the following is equivalent to the snippet above?

Engine.free() {this.price = 0;this.model = 'Free';this.weight = 10;}

Given this start of a class definition: class Engine {final int price;final String model;final int weight;Engine(this.price, this.model, this.weight); Which of the following is a valid implementation of a named constructor?

flutter --help

How might you find out about all the different things you can do with the flutter command line tool?

foo( (String s) => 'maybe' );

Imagine that the function foo exists, and the documentation describes how you must pass foo one thing: a function that accepts a String parameter and returns a String. Which of the following is a valid invocation of foo?

String myFunc(String s) {return 'maybe';}foo(myFunc);

Imagine that the function foo exists, and the documentation describes how you must pass foo one thing: a function that accepts a String parameter and returns a String. Which of the following snippets of code and example invocation of foo is valid?

Use a Flutter library/plugin to abstract the details specific to each platform

Imagine you're building an app that has notifications. Flutter is a cross-platform SDK. So how do you write code that creates notifications in both the Android and iOS runtime environments?

Source code that is "private" to the packge/project

In Dart projects, the lib directory is a little "special." Usually, the lib directory contains an src subdirectory, containing:

export statements referring to files within the lib subdirectory tree

In Dart projects, the lib directory is a little "special." Usually, the lib directory contains one .dart file which itself contains:

True

In Dart, constructor bodies may be omitted in some situations.

False

In Dart, constructors may be overloaded.

False

In Dart, semicolons indicating the end of a statement are optional.

False

In Dart, the parenthesis surrounding the condition in an if statement are optional, similar to Python, Ruby, or Go.

False

In Dart, you may not overload functions, but you can overload constructors.

relative layouts, MediaQuery API, and explicit code

In Flutter, developers primarily handle the ability for interfaces to "adapt" to the device screen and orientation with a combination of...

routes

In Flutter, the concept of navigation between screens manifests as...

Stateless, Stateful

In the Flutter SDK, the two primary kinds of widgets are...

A user interface component, providing a `build` function , that determines what they look like

In the Flutter environment, almost everything is a widget. What is a widget?

setState

In the Flutter framework, what function triggers a call to `build`, causing an update to the visual UI?

Mobile Web / PWA, React Native

One benefit to UI design with Flutter is that it adheres to Material Design, "baked in" to the SDK. Which of the following mobile SDKs lacks such a design standard?

Instead of creating thousands of names all at once, the widget creates ten at a time, as needed

Part 1 of our project describes our list of startup names as a "lazily loaded" list. What is "lazy" about it?

storing/retrieving data with a relational database, traditional file I/O, key-value pairs of user preferences

Persisting data on mobile devices usually takes place in the form of...

BuildContext, representing information about the location of the widget in the tree

The canonical build method receives one argument. What is its type, and what does it represent?

Swift UI

The iOS SDK has a new, different approach to building user interfaces - and it seems very similar to Flutter. What is it?

False

The main benefit of using iOS/Android native SDKs is that only native iOS and Android SDKs have access to hardware, such as the camera or location services.

main

The main entry point of a Dart program is a function named:

cross-platform development, user interface performance

Two of the benefits prioritized by Flutter include...

False

Type annotations in Dart are optional, indicating that Dart is a dynamically typed language.

ThemeData

What class might we use to control the visual appearance of our Flutter app?

stack

What data structure does Flutter's Navigator use?

Software Development Kit

What does the acronym SDK stand for?

A stateless widget is immutable and does not change; a stateful widget has external information (state) that affects its behavior/appearance

What is the main difference between a stateless widget and a stateful widget?

flutter doctor

What is the proper flutter command-line option for checking the status of your development environment?

We use the editor/IDE for writing code

What role does the text editor or IDE play in the workflow of building mobile applications?

performance profiling tools, devices / runtime platform, UI design tools and guidelines, responsiveness, data storage, developer toolchain (IDE, etc), programming language

When considering and exploring new mobile SDKs, some attributes to consider include...

request access, requiring user confirmation

When creating mobile applications that rely on device services, such as the camera or location, applications should...

Xcode

Which IDE is used for native iOS development?

ListView

Which component was used to present a scrollable list of widgets?

Django, Ruby on Rails, Dart, NodeJS, Kotlin, Swift

Which of the following are not a primary mobile development SDK?

Chrome dev tools, Flutter DevTools/Observatory, Android Profiler, systrace, Instruments

Which of the following are tools for profiling the performance of mobile applications?

Genymotion, Android Emulator,

Which of the following are used by Android developers for running their apps during development? (Select multiple.)

var name; int name; const name = 42; final name = 42;

Which of the following are valid variable declarations in Dart?

Standard libs first, then external packages, then internal packages, then relative imports.

Which of the following best describes the ordering convention of import statements in Dart?

class Spaceship {String _name;}

Which of the following class definitions properly defines a private instance variable?

enum Method { get, post, put, patch, delete, head }

Which of the following defines a valid enumerated type?

iOS with Java (or Swift), iOS with JavaScript, Android with JavaScript

Which of the following does not describe the right language used within the SDK? (Select multiple.)

int increase(int value) => value + 10;

Which of the following function implementations is equivalent to: int increase(int value) {return value + 10;}

import 'package:firefly/armada.dart';

Which of the following import statements uses a syntactically valid URI?

Map<String, int>, Map<String, Planet>, Map<String, String>, Map<Planet, String>

Which of the following is a valid Map data type? (Select multiple)

Center

Which of the following widget types is used for aligning the contents of its subtree to the middle of itself?

Google Firebase services

While the market for in-app analytics used to consist of many third-party products, many of them have been purchased and integrated into...

The project root includes a pubspec.yaml file for declaring library dependencies The bin directory contains main.dart, containing the "main" code for the program The lib directory contains additional source files used in the project The test directory contains source files for the test suite

While you can create an arbitrary project structure, most language ecosystems follow particular conventions for project organization. When we use the stagehand library to organize a project, which of the following are true about the project structure?

"Widgets grow on trees," or, the SDK pre-caches app widgets in a tree-like structure for fast state changes and re-rendering

Why are Flutter applications referred to as "trees" of widgets?


Conjuntos de estudio relacionados

Chap 71 Mass Casualty and Disaster Preparedness

View Set

Series and Sequences Review (chapter 10 precalc honors)

View Set