Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Document preview thumbnail
Vista previa 2 fuera de 8 páginas
Examen

CSCE 314 Past Quiz Questions with correct answers 2024_2025

Document preview thumbnail
Vista previa 2 fuera de 8 páginas

Typical programming language implementation involves the following (unordered) major steps. Which step would result in a type-annotated parse tree? a. Parsing b. Type checking c. Optimization d. Machine code generation e. Lexical analysis b. Type checking Typical programming language implementation involves the following unordered major steps. Correctly order the steps, in which a language system generates an executable code from given source code. Machine code generation Lexical analysis Parsing Optimization Type checking 1. Lexical analysis 2. Parsing 3. Type checking 4. Optimization 5. Machine code generation Previous Play Next Rewind 10 seconds Move forward 10 seconds Unmute 0:00 / 0:15 Full screen Brainpower Read More Typical programming language implementation involves the following (unordered) major steps. Which step generates a syntax tree, given a stream of tokens as input, by checking whether the program is written according to the grammar? a. Optimization b. Lexical analysis c. Parsing d. Type checking e. Machine code generation c. Parsing Consider the following Haskell definition of the list Monad. instance Monad [] where -- (=) :: [a] - (a - [b]) - [b] xs = f = [y | x - xs, y - f x ] Suppose that you are showing the step-by-step of the following expression explaining how the = operator works: [1,2] = x - [x..3] = y - return (y+1) Which one of the following values is not a value of y while evaluating the above expression?If every value is a value of y, then choose "All values are values of y." 1 2 3 4 All values are values of y 4 Given the following declaration of Haskell class Functor. class Functor f wherefmap :: (a - b) - f a - f b What can go in the underlined space below so that the Functor laws are preserved? instance Functor Maybe where fmap _ Nothing = Nothing fmap f (Just x) = __________ a. Just (f x) b. f (Just x) c. Just f x d. f x e. Just f f. Just x a. Just (f x) Typical programming language implementation involves the following (unordered) major steps. Which step would generate a token table from a stream of characters? a. Machine code generation b. Lexical analysis c. Parsing d. Optimization e. Type checking b. Lexical analysis Consider the following Haskell definitions. instance Applicative [ ] where pure x = [x] gs * xs = [ g x | g - gs, x - xs ] Suppose that you are writing down the step-by-step of the following expression explaining how the * operator works: pure div [4,3] [2,1] Which one of the following expressions is not part of the step-by-step explanation? a. (div 3 1) b. (div 4 1) c. (div 3 2) d. (div 2 1) e. All appear in the evaluation steps. d. (div 2 1) Consider the grammar G=({S},{0,1},{S→000S,S→1},S)G=({S},{0,1},{S→000S,S→1},S) and the language L(G)L(G) that is generated by GG. Which one of the following is a correct statement? a. None of the other four choices are correct. b. both G and L(G) are not regular c. both G and L(G) are regular d. G is not regular, but L(G) is regular e. G is regular, but L(G) is not regular d. G is not regular, but L(G) is regular Typical programming language implementation involves the following (unordered) major steps. In which step regular grammars would most likely be used? a. Parsing b. Type checking c. Lexical analysis d. Machine code generation e. Optimization c. Lexical analysis Let LL be the formal language of bit strings such that each word in LL has length ≥4≥4 and has the same number of 00s and 11s. Which type(s) of language in the Chomsky Hierarchy does LL belong to? Choose all that apply. a. Phrase structure language b. Context-free language c. Context sensitive language d. It does not belong to any of the given types. e. Regular language a, b, c Check all that apply. The language {ambn∣m≥1 and n≥0}{ambn∣m≥1 and n≥0} is a __________. a. Regular language b. Phrase structure language c. Context sensitive language d. Context-free language e. None of the other four choices a, c Typical programming language implementation involves the following (unordered) major steps. In which step context-free grammars would most likely be used? a. Lexical analysis b. Machine code generation c. Parsing d. Type checking e. Optimization c. Parsing Is the following grammar in BNF ambiguous (yes) or not ambiguous (no)? expr ::= expr + number | expr - number | number number ::= digit | digit number | expr digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 ambiguous Which of the following is not a wrapper class for a primitive type of Java? a. Character b. String c. Boolean d. Short e. Byte f. Long b. String Choose a correct word for blank (A). "Anonymous inner classes are defined in the (A) expression itself." Choices: nested, new, old, inner, outer, static, dynamic, abstract, final, type inner Fill in the blank (A) with a correct word (with correct spelling): Newly created objects are allocated within an area of JVM runtime memory known as the (A). heap True or false: All method declarations in an interface, including default methods, are implicitly private. false, they are implicitly private Which one of the following is not true about Java? a. Java aims for platform dependence for security. b. Java provides built-in support for computer networks. c. Java uses both static binding and dynamic binding. d. Java allows executing code from remote sources. a. Java aims for platform dependence for security. True or false: Inner classes have access to other members of the enclosing class, including private members. true Fill in the blank (A) with a correct word (with correct spelling): A field declared (A) can only be accessed by the methods in the current class. private Fill in the blank (A) with a correct word (with correct spelling; it is case sensitive): Class (A) is the root of the class hierarchy in Java. Object True or false: A static nested class is associated with its enclosing class. true Consider the following subtype/supertype relation. A is subtype of B B is supertype of C C is subtype of A What can you infer? a. A : B : C b. B : C : A c. A : C : B d. B : A : C e. C : B : A f. C : A : B f. C : A : B Fill in the blank (A) with a correct word (with correct spelling): A method declared (A) belongs to the class and is not associated with a particular instance of the class. Choices: nested, new, old, inner, outer, static, dynamic, abstract, final, type static True or false: Local inner classes are members of the enclosing class. false What does "type safety" mean in relation to generics? a. It means eliminating parametric polymorphism to avoid type errors. b. It means delaying compile time error checking to run time. c. It means reducing compile errors as much as possible. d. It means catching more errors at compile time. d. It means catching more errors at compile time. Consider the following code: List? aList = new LinkedListString(); aL("Hi"); // compile error Which one of the following is not part of the verbose compile error message? a. method L(int,CAP#1) is not applicable b. CAP#1 extends Object from capture of ? c. CAP#1 is a fresh type-variable d. Object cannot be converted to CAP#1 d. Object cannot be converted to CAP#1 Consider the following code snippet without generics: List l = new LinkedList(); (IOf(7)); Integer x = (Integer) (0); // this line In "this line" above, what would happen without type cast? a. Compile error saying that Object cannot be converted to Integer. b. Compile error saying that the index out of bound. c. It will still compile by auto-boxing/unboxing. d. Compile error saying that such value does not exist. e. Compile error saying that the get() method does not exist. a. Compile error saying that Object cannot be converted to Integer. What is the actual output of the following code snippet? Answer exactly as it will be shown. ListDouble l1 = new ArrayListDouble(); ArrayListString l2 = new ArrayListString(); Sln(Class() == Class()); true false 0 1 true Assume BT : AT and MyInt : Integer : Number. Is the following true (safe) or false (unsafe) in Java? A? extends Number : A? super Integer unsafe Suppose Car : Vehicle, and method m defined in the Vehicle class has the signature: m : Vehicle - Vehicle The Car class is overriding method m. Which of the following are possible type signatures allowed by Java of the overriding method m of Car? Choose all that apply. a. m : Vehicle - Vehicle b. m : Car - Vehicle c. m : Car - Car d. m : Vehicle - Car a, d Consider the following code snippet with generics: List integer l = new LinkedList integer(); (IOf(7)); String x = (0); // this line In "this line" above, what would happen? a. It will compile, but at run time, a bad cast exception will occur. b. Compile error because you need type cast the return value of get() to String. c. It does not cause any problem; it will compile and run just fine. d. Compile error because Integer cannot be converted to String. e. Compile error because Object cannot be converted to Integer. d. Compile error because Integer cannot be converted to String. Assume BT : AT and MyInt : Integer : Number. Is the following true (safe) or false (unsafe) in Java? B? super Number : B? safe In the following instantiation of the generic class Pair, PairInteger, String p2 = new Pair(2, "two"); what would happen with the empty brackets ? a. A compile error will happen. b. Type inference will happen. c. A runtime exception will occur. d. It will clear the values of p2. b. Type inference will happen. True or false: When you "invoke" the generic type with specific types as the type arguments, the type arguments must be non-primitive type such as class or interface type. true Which one of the following is a correct statement regarding type parameter constraints? a. If no constraints are given, the constraint "extends Object" is assumed. b. None of the other four choices are correct. c. To be able to use the toString() method, you need to do "extends String". d. Multiple constraints for a single type parameter are not allowed. e. The only type parameter constraint Java allows is "extends Object". a. If no constraints are given, the constraint "extends Object" is assumed. Suppose ArrayListT : ListT and Integer : Number. Is the following true (safe) or false (unsafe) in Java? ArrayListInteger : ListNumber unsafe Add or remove terms Choo

Vista previa del contenido

CSCE 314 Past Quiz Questions with
correct answers 2024/2025




Typical programming language implementation involves the following
(unordered) major steps.
Which step would result in a type-annotated parse tree?
a. Parsing
b. Type checking
c. Optimization
d. Machine code generation
e. Lexical analysis - ANSWER- b. Type checking

Typical programming language implementation involves the following unordered
major steps.
Correctly order the steps, in which a language system generates an executable
code from given source code.
Machine code generation
Lexical analysis
Parsing
Optimization
Type checking - ANSWER- 1. Lexical analysis
2. Parsing
3. Type checking
4. Optimization
5. Machine code generation

Typical programming language implementation involves the following
(unordered) major steps.
Which step generates a syntax tree, given a stream of tokens as input, by
checking whether the program is written according to the grammar?
a. Optimization

, b. Lexical analysis
c. Parsing
d. Type checking
e. Machine code generation - ANSWER- c. Parsing

Consider the following Haskell definition of the list Monad.
instance Monad [] where
-- (>>=) :: [a] -> (a -> [b]) -> [b]
xs >>= f = [y | x <- xs, y <- f x ]
Suppose that you are showing the step-by-step of the following expression
explaining how the >>= operator works:
[1,2] >>= \x -> [x..3] >>= \y -> return (y+1)
Which one of the following values is not a value of y while evaluating the above
expression?If every value is a value of y, then choose "All values are values of y."

1
2
3
4
All values are values of y - ANSWER- 4

Given the following declaration of Haskell class Functor.

class Functor f wherefmap :: (a -> b) -> f a -> f b

What can go in the underlined space below so that the Functor laws are
preserved?
instance Functor Maybe where
fmap _ Nothing = Nothing
fmap f (Just x) = __________

a. Just (f x)
b. f (Just x)
c. Just f x
d. f x
e. Just f
f. Just x - ANSWER- a. Just (f x)

Typical programming language implementation involves the following
(unordered) major steps.
Which step would generate a token table from a stream of characters?

Información del documento

Subido en
10 de septiembre de 2024
Número de páginas
8
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas
$11.99

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
BRAINSCAPE1
4.4
(20)
Vendido
141
Seguidores
15
Artículos
11136
Última venta
3 semanas hace



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes