Python and Java Programming Fundamentals

Test your knowledge of basic programming concepts in Python and Java, including control flow, object-oriented programming, syntax, and data structures

20 Questions Published

Questions

Question 1 True/False

Do the list structure can have different data types ?

  1. True
  2. False
Question 2 True/False

Do the negative indices are allowed in Python ?

  1. True
  2. False
Question 3 Multiple Choice (Single Answer)

Which is the following invalid structure/syntax in python ?

  1. list
  2. module
  3. sequence
  4. lib
Question 4 Multiple Choice (Single Answer)

Function definition in python prefix with _____ .

  1. function
  2. def
  3. void
  4. func
Question 5 Multiple Choice (Single Answer)

A class or a function definition in python ends with _____

  1. semicolon
  2. parentheses
  3. colon
  4. angle bracket
Question 6 Multiple Choice (Single Answer)

Identify the correct syntax for instantiating a class .

  1. testObj = CTest
  2. testObj = CTest()
  3. CTest testObj = CTest()
  4. testObj = new CTest()
Question 7 Multiple Choice (Single Answer)

Identify the correct syntax for instantiating a class .

  1. testObj = CTest
  2. testObj = CTest()
  3. CTest testObj = CTest()
  4. testObj = new CTest()
Question 8 Multiple Choice (Single Answer)

The constructor in python is _____

  1. def_init()
  2. name of class itself.
  3. python_init_
  4. init
Question 9 Multiple Choice (Single Answer)

Variable in python are by default ______

  1. public
  2. private
  3. global
  4. protected
Question 10 Multiple Choice (Single Answer)

How to initialize the variable with private scope ?

  1. Prefix the string 'private' to the variable name.
  2. initialize it with '_init_private'
  3. initialize it with double underscore '__'
  4. append the keyword 'pvt' before the variable.
Question 11 True/False

Can we give argument values to the parameters which are not at the end of the parameter list in the function definition ?

  1. True
  2. False
Question 12 True/False

In java local variables are automatically instantiated(T/F)

  1. True
  2. False
Question 13 Multiple Choice (Single Answer)

What gets printed after this boolean b = false; if (b = true){ System.out.println("True"); }

  1. Prints "True"
  2. Prints nothing
  3. Prints false
  4. Error in if condition
Question 14 Multiple Choice (Single Answer)

What is "instanceOf" ?

  1. an operator
  2. a method
  3. nothing
  4. a keyword in Java
Question 15 Multiple Choice (Single Answer)

For Object A to access method of object B, and the method has no modifier, Object A must be an instance of class which is ...

  1. Same package as B
  2. In different package
  3. mark a default acess modifier to the class
  4. None
Question 16 True/False

Each source file should have a public class in it ?

  1. True
  2. False
Question 17 True/False

Methods which are marked as Protected can be accessed only by classes with in the same package?

  1. True
  2. False
Question 18 True/False

Can abstract classes have non - abstract methods?

  1. True
  2. False
Question 19 Multiple Choice (Single Answer)

In a switch construct the execution will continue till

  1. a match case is found
  2. a match case is found and break is encountered
  3. will continue till default
  4. none
Question 20 True/False

Using a break in a for loop , causes the loop to break out of the current iteration and jump to the next iteration of the loop...

  1. True
  2. False