dh_0e

[Programming Language] 중간 족보 정리 본문

Programming Language

[Programming Language] 중간 족보 정리

dh_0e 2025. 4. 26. 09:32

<객관식>

Which of the following describes Inheritance in Java?

  1. The main purpose of inheritance is for reuse. (O) >> 재사용 목적
  2. Method in parent class cannot be overridden. (X)
    • >> Method in parent class can be overridden. (O)
  3. Child class may inherit methods in parent class selectively. (X)
    • >> Child class may not inherit methods in parent class selectively. (O)
  4. Child class can have two parent classes for inheritance. (X)
    • >> Child class can have a only parent class for inheritance. (O)
    • >> Child class can not have more than two parent classes for inheritance. (O)
  5. Constructor in parent class is also inherited. (X)
    • >> Constructor in parent class is not inherited. (O)

Which of the following describes "Functional Side Effect"?

  1. It occurs when the function changes a global variable. (O) >> 함수에서 전역 변수를 변경하는 경우 발생하는 부작용임
    • It occurs when the function changes a local variable. (X)
  2. It occurs when functions are overloaded. (X)
  3. It does not occur if there is no dynamic variables. (X)
  4. It occurs when the call-by-value parameter is used. (X)
  5. It occurs when functions are called recursively. (X)

Which of the following describes "Top-down(LL) parser"?

  1. It traces the parse tree in inorder. (X)
    • >> It traces the parse tree in postorder. (O)
  2. It is based on leftmost derivation. (O)
    • >> It is based on rightmost derivation. (X)
  3. Parsing table is used for parsing. (O, X) >> TL parser에 쓰임
  4. The parse tree is built from the leaves towards the root. >> TL 방식임
    • The parse tree is built from the root towards the leaves. (O)
  5. Parsing is done if there are no non-terminal symbols left. (O)

Which of the following describes "Stack" area for variable allocation?

  1. Global variables are allocated. (X) >> Static/전역 변수 영역
  2. It has memory-less characteristics. (O) >> 함수가 종료되면 지역 변수는 사라지기 때문에 이전 호출 값은 기억하지 않음
  3. Local variables are allocated. (O) >> Local  변수는 Stack 영역에 저장
  4. Dangling pointer problem may occur. (X) >> Heap/동적 자료구조 영역에서 발생
  5. Dynamic data variables are allocated. (X) >> Heap/동적 자료구조 영역에 생성
  6. Variables are statically allocated. (X) >> Static/정적 변수 영역

Which one is correct for "Pure Interpreter" approach?

  1. Usually used for Web scripting languages. (O) >> like Python
  2. Source-level debugging is possible. (O) >> 소스 코드를 라인 단위로 처리함
  3. Fast execution speed. (X) >> 속도가 느림
    • Slow execution speed. (O)
  4. Intermediate code is used. (X) >> intermediate code를 사용하지 않음
    • Intermediate code is not used. (O)
  5. Portability is easily achieved. (O) >> 이식성이 높음


Which of the following is related to Subprogram (or method) Overloading?

  1. Encapsulation (X) >> Object-Oriented L.의 특징
  2. Information hiding (X) >> Object-Oreinted L.의 특
  3. Polymorphism (O) >> 컴파일 타임 다형성
  4. Multiple constructors in Java (O) >> overloading을 사용하여 생성자 2개 이상 가능
  5. Recursive Functions (X) >> 재귀랑 관련 없음

Which of the following describes "Dangling Pointer"?

  1. Memory leakage problem occurs. (X) >> Garbage 관한 설명
  2. It is created by “new” operation in Java. (X) Java는 포인터 없음
  3. It is a pointer which points two or more data objects. (X) >> aliasing에 관한 설명
  4. It is a pointer that points another pointer variable. (X) >> pinter to pointer(이중 포인터)에 관한 설명
  5. It is a pointer that contains the address of stack variable.  (X) >> stack(지역) 변수는 빈 포인터 문제 없음
    • It is a pointer that contains the address of deallocated heap-dynamic variable (O)

Which of the following describes "Static Type Binding"(compared to "Dynamic Type Binding")?

  1. All variables should have the same data type. (X) >> type 상관 없음
  2. Runtime overhead is smaller. (O) 런타임 계산이 Dynamic 방식보다 적음
    • Runtime overhead is bigger. (X)
  3. It is an example of late binding. (X) >> Dynamic Binding 설명임
    • It is an example of fast binding. (O)
  4. Variable type is determined at compile time. (O) << 컴파일 타임에 변수들의 타입을 결정
  5. It is not possible to check type compatibility at compile time. (X) >> 컴파일 시점에서 체크 가능
    • It is possible to check type compatibility at compile time. (O)


Which of the following describes “Dynamic Scope” (Compared to “Static Scope”)?

  1. Runtime overhead is smaller. (X) >> 오히려 증가
    • Runtime overhead is bigger. (O)
  2. Readability is increased. (X) >> 오히려 감소
    • Readability is decreased. (O)
  3. Visible variables are determined at compile time. (X) >> Static Scope 특지임
    • Visable variables are determined at run time. (O)
  4. It is used in ALGOL60 or C or Java or Python or JS or Swift. (X) >> used in LISP, Bash, Perl (O)
  5. Referencing environment is determined by program structure. (X) >> Program structure=코드 구조

What is the role of Lexical Analyzer?

  1. It checks the ambiguity of grammar. (X) >> Parser 역할
  2. It handles the precedence of operators. (X) >> Parser 역할
  3. It generates intermediate codes. (X)  >> Syntax Analyser에게 넘겨주면 Intermediate code genereator가 만듬
  4. It serves as the back end of a syntax analyzer. (X)
    • It serves as the front end of a syntax analyzer. (O)
  5. It is a kind of pattern matcher. (O) lexemes의 패턴을 표현하는 방법

Which of the following describes the characteristics of “Strong Type Checking”?

  1. Coercion is usually used. (X) >> Weak type
  2. Compiler does not check type compatibility. (X) >> Weak type
  3. Dynamic type binding is allowed. (X) >> Forbidden
  4. C is a stronger type checking language than Java language. (X) Java, C# >>> C/C++
  5. “Structure Type Equivalence” is used rather than “Name Type Equivalence”. (X) 
    • Structure Type Equivalence = 구조가 같으면 같은 타입으로 인정 (Weak type)
    • Name Type Equivalence = 타입 이름이 같아야 같은 타입으로 인정 (Strong type)

Which one is correct about “Constructor” in Java?

  1. There may be many constructors in a class. (O) >> overloading 가능함
    1. There should be only one constructor in a class. (X)
  2. Constructor is used to create threads. (X) >> Thread 생성과 무관
  3. Constructor can not have parameters. (X) >> 가질 수 있음
    • Constructor may have parameters. (O)
  4. Constructor is executed when an instance is created. (O) >> 객체 생성 시 실행됨
  5. Compile time error occurs if there is no Constructor in a class. (X) >> 기본 생성자 자동 생성

What is an example of Aliasing?

  1. As the result of a = *b; in C language. (X) 
    • As the result of a = &b; in C language. (O)
  2. As the result of “new” operation in Java. (X) >> 별도 생성임
  3. Variables with same r-value. (X) >> 같은 r-value = 값(상수)를 가지는 건 Aliasing 아님
  4. Same named global variable and local variable. (X) Scope 충돌이지 aliasing 아님
  5. Formal parameter and Actual parameter in the cases of call-by-value. (X) 
    • Formal parameter and Actual parameter in the cases of call-by-reference. (O)
  6. Same named local variable. (X) 오류

Which of the following describes functions (or subprograms) in Imperative languages?

  1. It is a kind of Abstract Data Type. (X) ADT는 class에서 "데이터+연산"을 숨겨서 추상적으로 보여주는 개념
  2. It is a reusable unit. (O) 함수는 재사용 가능
  3. Runtime speed becomes faster. (X) 관련 없음
  4. It is a kind of Process Abstraction. (O) 구현 과정을 숨겨 추상적으로 보여줌
  5. It can have its own local variables. (O) 함수만의 지역변수 가짐

What are the general characteristics of major “Imperative Languages”, such as C?

  1. Dynamic scope rule is used. (X)
    • Static Scope rule is used. (O)
  2. Assignment statement is not used heavily. (X) Assignment statement가 중심임
  3. They are not affected by von-Neumann Architecture. (X) imperative L 본질이 von Neumann
  4. Dynamic type binding is used. (X) Static 바인딩 사용
  5. Interpreter is usually used for execution. (X) compiler 기반

Most compilers produce “intermediate code” before they make final machine codes.

Which one is correct about "intermediate code"?

  1. It is used to speed up compilation process. (X)
  2. It is sometimes used for code optimization. (O) 중간 코드에서 최적화를 많이 함
  3. Intermediate codes are used for object-oriented programming. (X) >> 객체지향언어랑 관련 없음
  4. It is used to check the syntactic errors in the program. (X) >> parsing 단계임
  5. Java’s “byte code” is an example. (O)

Which of the following describes “Heap” area?

  1. Union type data are allocated. (X) >> 원래는 stack에 저장
  2. Local variables are allocated. (X) >> stack에 저장됨
  3. Object codes are allocated. (X) >> 코드 segment에 저장
  4. Garbage collection is sometimes needed. (O) >> Java, Python 등에서 쓰임
  5. Static variables are allocated. (X) >> Static segment에 저장
  6. Variables are dynamically allocated. (O) >> 동적으로 저장됨

Which of the following describes ALGOL/ALGOL68?

  1. Recursive function call is not allowed. (X) allowed
  2. Dynamic scope is used. (X) Static Scope
  3. COBOL language is a descendant of ALGOL. (X)COBOL - FORTRAN
    • Pascal and C languages are descendants of ALGOL. (O)
  4. It is an object-oriented language. (X) 아님
  5. There are only two kind of variables: Global and Local. (X) 이외에 뭐가 되게 많음

Which of the following describes “Formal Parameter” in C language?

  1. It is a kind of “global” variable. (X) local variable
  2. It is a kind of “static” variable. (X) local임
  3. It is a kind of “dynamically created” (or heap) variable. (X) local임 stack
  4. It is a kind of “local” variable. (O)
  5. It must be a pointer variable. (X) 반드시 X

Which one is correct for Object-Oriented Programming?

  1. It increases coupling of modules. (X) 결합도 decerases
  2. It makes reuse of modules easier. (O) 재사용 굿
  3. It is based on Process Abstraction. (X) 구현과정 추상화는 imperative language의 기반임, OOP는 data abstraction임
  4. It’s major advantage is to make runtime faster. (X) 주요목적은 아님 느려질 수 있음
  5. It provides Encapsulation mechanism. (O) 캡슐화 제공

*Answer the questions on the following language. )23-24) $ and * are operators.

<assign> -> <id> = <expr> ;
<id> -> A | B | C
<expr> -> <term> $ <expr>
<term> -> <term> * <factor>
<factor> -> (<expr>) | <id>

Which one is correct about this grammar?

  1. $ is left associative. (X) 우측 재귀임
  2. “*” is right associative. (X) 좌측 재귀임
  3. $ has a higher precedence than *. (X) $가 상위 구조이므로 우선순위가 더 낮음
  4. “*” has a higher precedence than $. (O) 더 안쪽 구조이므로
  5. $ and * have same precedence. (X)
  6. This grammar is ambiguous. (X)

How many Nonterminal symbols and terminal symbols are there in this grammar. respectively? (Answer the nonterminal symbols first)

Nonterminal symbols: 5

Terminal symbols: 9 " A, B, C, =, ;, $, *, ), ( "

 

 

<빈칸>

Pointers are designed for two kinds of usages (Indirect addressing) and managing (dynamic variables).

In Java, (new) operator is used to create instance of class dynamically and In C, (&) is used to create the l-value of variables.

 

There are 4 different types of machine codes in Assembly languages.

Those are (load), (arithmetic and logical operations), (store) and (jump) instructions.

And jump instruction changes the value of (Program Counter) register in CPU.

 

CPU consists of (CU:Control Unit), (ALU) and various kinds of (Registers).

Imperative languages mainly consist of (assignment) statements and (control) statements.

And each instruction (i.e., machine code) is executed consisting of (fetch) and (decode) cycle in CPU.

 

Imperative languages mainly consist of assignment statements and (control) statements. And each instruction (i.e., machine code) is executed consisting of (fetch) and (execution) cycle.

 

In Java, “final” modifier is used with three different cases: “final (method)” cannot be overridden, “final (class)” cannot be inherited, and “final (variable)” cannot have other values.

 

LR Parsing algorithm is a kind of (Bottom-Up) parsers, which construct a parse tree by beginning at the (leaves) and processing towards the root. LR parser tries to find (handles), which is the RHS of BNF rules. When found, the action is (reduce).

 

There are three key features the Object-Oriented languages must provide : ADT(Abstract Data Type), (Inheritance) and Polymorphism. An ADT is an enclosure that includes (data) type and (subprogram). To implement Polymorphism, it is required (dynamic) binding of method calls to methods.

 

Parse Tree is useful for (Syntax) analysis while compiling. The (root) of the parse tree is “start symbol” of the Grammar. And “Non-terminal” symbol is replaced to (RHS) of its rule. A Grammar generates two or more distinct parse trees is said to be (ambiguous).

 

  1. ab<P>
  2. ac<P>
  3. aa<Q>
  4. aa

What is the most suitable language for the following applications?

(1) Functional Programming language LISP

(2) Script langue for Web PHP

(3) Mathematics & Science FORTRAN

(4) DoD Applications Ada

(5) Object-Oriented Programming Smalltalk