Java and C Programming Fundamentals

Questions covering Java threading, exceptions, OOP features, and C operators, data types, and arithmetic operations.

15 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Which of the following accessibility modes in Java does not allow a method to access the data members from the non-subclass of the same package?

  1. Protected
  2. Public
  3. Private
  4. No modifier
  5. Virtual
Question 2 Multiple Choice (Single Answer)

Which of the following methods of Iterator class throws NoSuchElementException, if the next element does not exist?

  1. hasNext()
  2. next()
  3. remove()
  4. add()
  5. nextIndex()
Question 3 Multiple Choice (Single Answer)

Which of the following Exception classes in Java is used to deal with an exception, where an assignment to an array element is of incompatible type?

  1. ArithmeticException
  2. ArrayIndexOutOfBoundsException
  3. IllegalArgumentException
  4. ArrayStoreException
  5. IllegalStateException
Question 4 Multiple Choice (Single Answer)

Which of the following methods is used in Thread class to resume the execution of a Thread class?

  1. yield()
  2. setName()
  3. resume()
  4. isAlive()
  5. start()
Question 5 Multiple Choice (Single Answer)

Which of the following methods in Java is used to identify that the input argument is a letter?

  1. isDefined()
  2. isDigit()
  3. isLetter()
  4. isLowerCase()
  5. isSpaceChar()
Question 6 Multiple Choice (Single Answer)

Which of the following methods in StringBuffer class concatenates two strings of different types to the end of the invoking string object?

  1. getChars()
  2. append()
  3. insert()
  4. reverse()
  5. delete()
Question 7 Multiple Choice (Single Answer)

Which of the following methods of Class returns the complete name of the class or interface of the invoking object?

  1. getSuperclass()
  2. isInterface()
  3. getName()
  4. toString()
  5. getClasses()
Question 8 Multiple Choice (Single Answer)

Consider the following C statement.
int a = 5;
printf(a = %usizeof(a));
What would be the output of the above C code?

  1. a = 1
  2. a = garbage value
  3. a = 2
  4. Compiler error
  5. None of these
Question 9 Multiple Choice (Single Answer)

Consider the following C statements.
int i,alpha = 65;
char ch[27];
for(i = 0;i<2;i++)
{
ch[i] = alpha;
alpha = alpha + 1;
}
printf(!!!^!!!%s!!!^!!!,ch);
What would be the output of the above C code?

  1. AB
  2. ABC
  3. 6566
  4. Compiler error
  5. 01
Question 10 Multiple Choice (Single Answer)

What would be the value of variables n and m in the following C code?
int n, m;
n = - 10;
m = - n + 5;
printf(!!!^!!!n = %dnm=%d!!!^!!!,n,m);

  1. n = - 10 m = - 5
  2. n = - 10 m = Garbage value
  3. n = - 10 m = 15
  4. n = 10 m = 5
  5. Compiler error
Question 11 Multiple Choice (Single Answer)

What would be the output of the following C statement?
char ch;
ch = 'A';ch = - ch + 'a';
printf(!!!^!!!ch = %d!!!^!!!,ch);

  1. ch = 162
  2. ch = 32
  3. ch = - 32
  4. Compiler error
  5. ch = 65
Question 12 Multiple Choice (Single Answer)

What would be the value of the following C code?
float a;
a = floor(6.523);
printf(!!!^!!!a = 0.2f!!!^!!!,a);

  1. a = 6.00
  2. a = 6.60
  3. a = 7.00
  4. a = 6.70
  5. Compiler error
Question 13 Multiple Choice (Single Answer)

By default, the floating-point value displays ______________ digits after the decimal point.

  1. 3
  2. 2
  3. 6
  4. 4
  5. none of these
Question 14 Multiple Choice (Single Answer)

Consider the following C statement.
int a = 3,b = 2;
a+ = b++;
printf(!!!^!!!a = %d!!!^!!!,a);
What would be the value of 'a'?

  1. a = 6
  2. a = 5
  3. a = 4
  4. a = 3
  5. Compiler error
Question 15 Multiple Choice (Single Answer)

Which of the following methods in Thread class, checks that the thread is a daemon thread?

  1. join()
  2. isDaemon()
  3. activeCount()
  4. sleep()
  5. start()