Programming Languages: C, C++, Java, and C# Fundamentals

Test your knowledge of fundamental concepts across multiple programming languages including C, C++, Java, and C#. Covers topics like object-oriented programming, threads, constructors, inheritance, and language-specific features.

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

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
Question 2 Multiple Choice (Single Answer)

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
Question 3 Multiple Choice (Single Answer)

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
Question 4 Multiple Choice (Single Answer)

First fully Object oriented language is:

  1. C++
  2. Java
  3. Simula
  4. None of the above
Question 5 Multiple Choice (Single Answer)

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
Question 6 Multiple Choice (Single Answer)

Which of the following exists in C++ ?

  1. virtual constructor
  2. virtual destructor
  3. both A and B
  4. None of the above
Question 7 Multiple Choice (Single Answer)

Reference to its own class can be accepted by:

  1. Simple constructor
  2. parameterized constructor
  3. copy constructor
  4. none of the above
Question 8 Multiple Choice (Single Answer)

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
Question 9 Multiple Choice (Single Answer)

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
Question 10 Multiple Choice (Single Answer)

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
Question 11 Multiple Choice (Single Answer)

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;
Question 12 Multiple Choice (Single Answer)

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
Question 13 Multiple Choice (Single Answer)

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<bestFriend>; }
Question 14 Multiple Choice (Single Answer)

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
Question 15 Multiple Choice (Single Answer)

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
Question 16 Multiple Choice (Multiple Answers)

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
Question 17 Multiple Choice (Single Answer)

The notation for preprocessor directive is :

  1. $
  2. !
  3. @
  4. #
Question 18 Multiple Choice (Multiple Answers)

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; }
Question 19 Multiple Choice (Single Answer)

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
Question 20 Multiple Choice (Single Answer)

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