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.
Questions
How can pointers be used in C#
- No,pointers can not be used here
- by using unsafe block
- by compiling using /unsafe option in command line only
- Both B and C
- None
Which of the Statements is true
- Static Variables are Set at RunTime
- Sealed classes cannot be Overriden
- finally' block executes only when exception occurs
- Both A and B
- Both B and C
What does 'new' keyword do when used as a modifier for a method (inheritance)?
- Adds a Reference to the parents class method
- it only hides the parent class method
- it overrides the parent class method
- None
- All the Above
First fully Object oriented language is:
- C++
- Java
- Simula
- None of the above
The member functions of a class can be defined outside the class using:
- extraction operator
- scope resolution operator
- insertion operator
- All the above
Which of the following exists in C++ ?
- virtual constructor
- virtual destructor
- both A and B
- None of the above
Reference to its own class can be accepted by:
- Simple constructor
- parameterized constructor
- copy constructor
- none of the above
Using pointers to call a function is called as:
- call by reference
- call by value
- call by address
- All the above
What will be the value of variable 'z' after execution of following code? int z; for(z=0;z<50;z++) {}
- 0
- 51
- 49
- 50
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?
- The output could be 8-1 7-2 8-2 7-1
- The output could be 6-1 6-2 5-1 5-2
- The output could be 6-1 5-2 6-2 5-1
- The output could be 6-1 6-2 5-1 7-1
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?
- Direction d = NORTH;
- Nav.Direction d = NORTH;
- Direction d = Direction.NORTH;
- Nav.Direction d = Nav.Direction.NORTH;
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?
- 0
- 1
- 2
- 3
Which Man class properly represents the relationship "Man has a best friend who is a Dog"?
- class Man extends Dog { }
- class Man implements Dog { }
- class Man { private BestFriend dog; }
- class Man { private Dog bestFriend; }
- class Man { private Dog<bestFriend>; }
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?
- any class
- only the Target class
- any class in the test package
- any class that extends Target
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?
- Looser coupling
- Tighter coupling
- Lower cohesion
- Higher cohesion
Which two statements are true? (Choose two.)
- It is possible for more than two threads to deadlock at once.
- The JVM implementation guarantees that multiple threads cannot enter into a
- Deadlocked threads release once their sleep() method's sleep duration has expired.
- Deadlocking can occur only when the wait(), notify(), and notifyAll() methods are
- It is possible for a single-threaded application to deadlock if synchronized blocks are
- . If a piece of code is capable of deadlocking, you cannot eliminate the possibility of
The notation for preprocessor directive is :
- $
- !
- @
- #
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.)
- public int blipvert(int x) { return 0; }
- private int blipvert(int x) { return 0; }
- private int blipvert(long x) { return 0; }
- protected long blipvert(int x) { return 0; }
- protected int blipvert(long x) { return 0; }
- protected long blipvert(long x) { return 0; }
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); }
- a=11 b=31
- a=10 b=30
- a=11 b=30
- None of the Above
Which of the following is used to receive a single string?
- gets
- getstring
- Both A and B
- None of the Above