0
Alien head

programming languages Online Quiz - 55

Description: programming languages Online Quiz - 55
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

Which of the following is used to receive a single string?

  1. gets

  2. getstring

  3. Both A and B

  4. None of the Above


Correct Option: A

What is the output of the following C program? main() { int a=10; int b; b=a++ + 20; printf("a=%d b=%d",a,b); }

  1. a=11 b=31

  2. a=10 b=30

  3. a=11 b=30

  4. None of the Above


Correct Option: C

Given: 1. public class Blip { 2. protected int blipvert(int x) { return 0; } 3. } 4. class Vert extends Blip { 310-065 10 5. // insert code here 6. } Which five methods, inserted independently at line 5, will compile? (Choose five.)

  1. public int blipvert(int x) { return 0; }

  2. private int blipvert(int x) { return 0; }

  3. private int blipvert(long x) { return 0; }

  4. protected long blipvert(int x) { return 0; }

  5. protected int blipvert(long x) { return 0; }

  6. protected long blipvert(long x) { return 0; }


Correct Option: A,C,E,F

The notation for preprocessor directive is :

  1. $

  2. !

  3. @

  4. #


Correct Option: D

Which two statements are true? (Choose two.)

  1. It is possible for more than two threads to deadlock at once.

  2. The JVM implementation guarantees that multiple threads cannot enter into a

  3. Deadlocked threads release once their sleep() method's sleep duration has expired.

  4. Deadlocking can occur only when the wait(), notify(), and notifyAll() methods are

  5. It is possible for a single-threaded application to deadlock if synchronized blocks are

  6. . If a piece of code is capable of deadlocking, you cannot eliminate the possibility of


Correct Option: A,F

A team of programmers is reviewing a proposed API for a new utility class. After some discussion, they realize that they can reduce the number of methods in the API without losing any functionality. If they implement the new design, which two OO principles will they be promoting?

  1. Looser coupling

  2. Tighter coupling

  3. Lower cohesion

  4. Higher cohesion


Correct Option: A

Given: 1. package test; 2. 3. class Target { 4. public String name = "hello"; 5. } What can directly access and change the value of the variable name?

  1. any class

  2. only the Target class

  3. any class in the test package

  4. any class that extends Target


Correct Option: C

Which Man class properly represents the relationship "Man has a best friend who is a Dog"?

  1. class Man extends Dog { }

  2. class Man implements Dog { }

  3. class Man { private BestFriend dog; }

  4. class Man { private Dog bestFriend; }

  5. class Man { private Dog; }


Correct Option: D

Given: 11. class Mud { 12. // insert code here 13. System.out.println("hi"); 14. } 15. } And the following five fragments: public static void main(String...a) { public static void main(String.* a) { public static void main(String... a) { public static void main(String[]... a) { public static void main(String...[] a) { How many of the code fragments, inserted independently at line 12, compile?

  1. 0

  2. 1

  3. 2

  4. 3


Correct Option: D

class Nav{ 11. public enum Direction { NORTH, SOUTH, EAST, WEST } 12. } 13. public class Sprite{ 14. // insert code here 15. } Which code, inserted at line 14, allows the Sprite class to compile?

  1. Direction d = NORTH;

  2. Nav.Direction d = NORTH;

  3. Direction d = Direction.NORTH;

  4. Nav.Direction d = Nav.Direction.NORTH;


Correct Option: D

class PingPong2 { synchronized void hit(long n) { for(int i = 1; i < 3; i++) System.out.print(n + "-" + i + " "); } } public class Tester implements Runnable { static PingPong2 pp2 = new PingPong2(); public static void main(String[] args) { new Thread(new Tester()).start(); new Thread(new Tester()).start(); } public void run() { pp2.hit(Thread.currentThread().getId()); } } Which statement is true?

  1. The output could be 8-1 7-2 8-2 7-1

  2. The output could be 6-1 6-2 5-1 5-2

  3. The output could be 6-1 5-2 6-2 5-1

  4. The output could be 6-1 6-2 5-1 7-1


Correct Option: B

What will be the value of variable 'z' after execution of following code? int z; for(z=0;z<50;z++) {}

  1. 0

  2. 51

  3. 49

  4. 50


Correct Option: D

Using pointers to call a function is called as:

  1. call by reference

  2. call by value

  3. call by address

  4. All the above


Correct Option: A

Reference to its own class can be accepted by:

  1. Simple constructor

  2. parameterized constructor

  3. copy constructor

  4. none of the above


Correct Option: C

Which of the following exists in C++ ?

  1. virtual constructor

  2. virtual destructor

  3. both A and B

  4. None of the above


Correct Option: B

The member functions of a class can be defined outside the class using:

  1. extraction operator

  2. scope resolution operator

  3. insertion operator

  4. All the above


Correct Option: B

First fully Object oriented language is:

  1. C++

  2. Java

  3. Simula

  4. None of the above


Correct Option: C

What does 'new' keyword do when used as a modifier for a method (inheritance)?

  1. Adds a Reference to the parents class method

  2. it only hides the parent class method

  3. it overrides the parent class method

  4. None

  5. All the Above


Correct Option: B

Which of the Statements is true

  1. Static Variables are Set at RunTime

  2. Sealed classes cannot be Overriden

  3. finally' block executes only when exception occurs

  4. Both A and B

  5. Both B and C


Correct Option: D

How can pointers be used in C#

  1. No,pointers can not be used here

  2. by using unsafe block

  3. by compiling using /unsafe option in command line only

  4. Both B and C

  5. None


Correct Option: D
+ View questions