Search This Blog

Saturday, May 31, 2025

Java History - Virtual Threads

 Virtual threads were introduced as a part of the project Loom. Virtual threads are lightweight when it comes to memory and CPU overhead. Virtual threads have less context switching cost than native threads.

Virtual threads are suitable for tasks like I/O, where a thread is blocked for most of the time, like in a server application. Virtual threads are not fast.

Virtual threads were introduced and finalized in different versions of Java.

In which version of Java were virtual threads introduced and finalized?

a) Version 17 and 20

b) Version 17 and 19

c) Version 19 and 20

d) Version 19 and 21


Created by Nancy N.

@13:50 31-May-2025

Friday, May 30, 2025

Java History - Varargs

 Varargs (Variable-length arguments), as the name suggests, is a concept that allows a method to receive a variable number of arguments. When you use the varargs method, you do not need to overload a method, for example:  int add (int ... n){}, this add method can be called by passing any number of integer values. Although it may seem that overloading is not required, in some cases where you want to overload a method with different data type arguments, overloading is the way to go.

In which version of Java Varargs concept was introduced?

a) Version 4

b) Version 5

c) Version 7

d) Version 9


Created by Nancy N.

@12:44 3-=May-2025

Thursday, May 29, 2025

Java - Versions History

 In which version of Java were Generics was introduced?

a) Version 3

b) Version 5

c) Version 6

d) version 7


Created by Nancy N.

@29-May-2025


Wednesday, May 28, 2025

Java - Inheritance

 Which of the following keywords is used to inherit an interface?

a) implement

b) extends

c) extend

d) super


Created by Nancy N.

@12:09 28-May-2025


Monday, May 26, 2025

Java Comments

 Which of the following is not a valid Java comment?

a) <! comment !>

b) /**  @version 1 */

c) /* Java comment */

d) // java comment

e) # java comment


Type your answer in a comment


Created by Nancy N.

@1:08 27-May-2025

Friday, May 23, 2025

Java Multi Threading - 1

 Which methods will you implement to incorporate user-defined threads in your Java program?

a) start()

b) join()

c) run()

d) yield()


Created by Nancy N.

@12:43 23-May-2025


Wednesday, May 21, 2025

Java - Runnable

Which of the following is true about Runnable?

a) Runnable is a class

b) Runnable is a method in the Thread class

c) Runnable is an interface

d) Runnable is a checked exception required to be handled by every class extending the Thread class


Post your answer in a comment.


Created by Nancy N.

@21-May-2025

Tuesday, May 20, 2025

Java Access Specifiers

 Which of the following is not a Java Access Specifier?

a) private

b) volatile

c) protected

d) unprotected

e) static

f) public

g) transient


Created by Nancy N

@11:03 21-May-2025



Friday, May 16, 2025

Java String Class

In which package is the String class declared?

a) java.util

b) java.io

c) java.lang

d) java.text

e) java.textstrings


Type your answer in the comment.


Created by Nancy N.

@13:42 16-May-2025


Thursday, May 15, 2025

SortedMap Interface

Which of the following classes implements the SortedMap interface?

a) HashTable

b) TreeSet

c) TreeMap

d) HashSet

e) ConcurrentSkipListMap


Type your answer in a comment. 


Created By Nancy N.

@13:32 15-May-2025

Tuesday, May 13, 2025

Function Pointers in C

 A C pointer is a variable that holds the address of another variable. Can it hold the address of a function? The answer is YES. You can declare a pointer variable and store the address of a function in this variable. 

int add(int,int);

int *funptr=&add;

Or you can also assign a function name to the pointer instead.

int *funptr=add;

In C, a function name acts as a constant pointer to the function, so you can omit the & (address operator).

One of the benefits is that the same pointer variable can call different functions depending on which function it is pointing to. Using a function pointer, you can call the functions dynamically. It is useful when you want to pass a function as an argument. Here is an example:


At line 9, when you assign funptr the value of add, it stores the address of the function add and points to the function add:


When you call (*funptr)(9,7), it calls the add function and returns the sum.

At line 12, when you assign the address of the multiply function to funptr, it now points to the function multiply:


Now, on call, (*funptr)(3,9), it returns the product of numbers.

CAUTION - When you use a function pointer, it can point to different functions with the same signature (same number of parameters, same type, and order).

When the program is compiled, linked, and run, the output is:


More on function pointers, in another post...

Subscribe, share, and follow for more

Created by Nancy N.
@2:40 14-May-2025

 








Monday, May 12, 2025

Programming Errors

Three types of programming errors are:

a) Compile-time error - caused by syntax, for example, boolen flag = false;

b) Runtime error—caused by unexpected conditions or invalid operations, such as memory overflow or opening a file that does not exist.

c) Logical error - programmer's logic faults - for example, faulty condition: if (x > y) print x is small


Created by Nancy N.

@11:30 am 12-May-2025



Sunday, May 11, 2025

Dependency Injection

 Is Dependency injection a design pattern?

a) Yes

b) No


Created by Nancy N.

@12:02 11-May-2025

Saturday, May 10, 2025

Functions and Pointers in C - 2

Pointers in C are one of the strongest features if used thoughtfully. Pointer variables allow you to access a value in memory using its address. Here is a code for your brain exercise.  

Study the code given below. What will happen when you compile and run this code?





Type your answer in the comment.

Created by Nancy N.
@12:01 10-May-2025








Friday, May 9, 2025

In which category will you put C Programming language?

 In which category will you put the C Programming language?

a) High-level language

b) Machine-level language

c) Middle-level language

d) Low-level language


Type your answer in a comment.


Created by Nancy N.

@13:14 09-May-2025

Wednesday, May 7, 2025

Gang of Four Patterns - 2

 Design patterns are reusable elements that provide standard solutions for software design issues. Gang of Four Design patterns are categorised into Creational, Structural, and Behavioural. Do you know how many total Gang of Four patterns there are?

a) 20

b) 32

c) 23

d) 45


Created by Nancy N.

@14:07 07-May-2025

Tuesday, May 6, 2025

Interesting Facts about Java - 4

 Java was not created for the Internet. It was developed to serve the need for a platform-independent (architecture-neutral) programming language for embedded software for consumer electronics like remote controls. 

C and C++ were the popular programming languages for embedded software (still in use). The problem was that C and C++ programs need to be compiled every time you want to run them on a different processor. So you needed a separate compiler for every target. James Gosling and the team wanted to design a programming language that could address this compilation-related issue. Java was created to be compiled to bytecodes, which are independent of the target platform.


Created by Nancy N.

@10:21 06-may-2025

Thursday, May 1, 2025

Object-Oriented Programming - Generalization

 In object-oriented programming, Generalization is achieved by 

 A. Inheritance

 B. Polymorphism 

 C. Encapsulation 

 D. Abstraction


Type your answer in a comment.


Created by: Nancy N

@01:30 02-May-2025



Gang of Four Design Patterns

 In 1994, Eric Gamma, Richard Helm, Ralph Johnson, and John Vissides introduced the GoF (Gang of Four) design patterns. These design patterns addressed the common design problems and their solutions. These patterns addressed problems and solutions for which of the following type of programming:

a) Procedural programming

b) Object-based programming

c) Markup programming

d) Object-Oriented Programming


Type your answer in the comment.


Share this blog with your friends and also with those who are not your friends.

Subscribe to my blog for more interesting questions, codes, and articles...


By Nancy N

@11:54 01-May-2025