Monday, September 30, 2024

Function in C Language

Function in C

Function:-

The fundamental component of a C program that facilitates modularity and promotes code reusability is the function. Functions are employed to execute specific tasks, and they play a crucial role in enabling code reuse: by defining the code once, it can be utilized multiple times.
  • A function carries out some specific well defined tasks.

  • A function will carry out its intended contains whenever it access or called.

  • Same function can be access from several different places within a program.

  • A function will process information passed in it from the calling portion.

syntax:-

return type function_name(arguement)
{
//-----
//-----
}
return (-);

syntax of a function for designing of format like (-).

    (------------------------)
draw();

draw(){ printf("\n ----------------------------");}


A- function with no arguement and no return.

sum(); / sum(){}

B- function with arguement and no return.

sum(a,b); / sum(int x, int y){z=x+y;}

C- function with arguement and return.

c=sum(a,b); / sum(int x, int y){ z=x+y; return(z);}

Need of function for repetitive task.

#include<stdio.h>
#include<conio.h>
main()
{
clrscr();
printf("\n --------------------");
printf("\n Employee Details");
printf("\n --------------------");
printf("\n Name Age Salary");
printf("\n Amit 20 15000");
printf("\n Sumit 22 20000");
printf("\n --------------------");
printf("\n Devloped by");
printf("\n Pankaj Kumar Dubey");
printf("\n --------------------");
getch();
}


Function with No argument No return.

This program print dashline where it is called.

#include<stdio.h>
#include<conio.h>
main()
{
clrscr();
dashline(); // function call shows dashline
printf("\n Employee Detail");
dashline(); //function call shows dashline
printf("\n Name Age Salary");
dashline(); //function call shows dashline
printf("\n Amit 20 15000");
printf("\n Sumit 22 22000");
dashline(); //function call shows dashline
printf("\n Developed by");
printf("\n Pankaj Kumar Dubey");
dashline(); //function call shows dashline
getch();
}

//function definition.

dashline()
{
printf("\n ----------------------------");
}

Function with argument No return.

#include<stdio.h>
#include<conio.h>
main()
{
clrscr();
dashline(*); // function call shows * line.
printf("\n Employee Detail");
dashline(#); // function call shows # line.
printf("\n Name Age Salary");
dashline($); // function call shows $ line.
printf("\n Amit 20 15000");
printf("\n Sumit 22 22000");
dashline($); // function call shows # line.
printf("\n Developed by");
printf("\n Pankaj Kumar Dubey");
dashline(*); // function call shows * line.
getch();
}

//function definition - whatever character send to at 'p' i.e. printed from where it is called like that '*', '#', '$'.

dashline(char p)
{
int i;
printf("\n");
for(i=0;i<=30;i++)
{
printf("%c",p);
}
}


Function with No argument No return.

//This program has a function name sum() that demands 2 input and calculate their addition where it is called.

// this function demands different-different values every time when it is called.

#include<stdio.h>
#include<conio.h>
main()
{
clrscr();
sum();         //function with no argument i.e. sum() called here.
getch();
}

//function definition.

sum()
{
int a,b,c;
printf("\n Enter the value of a ");
scanf("%d",&a);
printf("\n Enter the value of b ");
scanf("%d",&b);
c=a+b;
printf("\n The value of sum is %d",c);
}


Function with argument No return.


//This program has a function with argument i.e. sum(a,b) used to pass the values only for calculation.

//this function returns same value every time because the values are taken in main() function before called to sum(a,b).

#include<stdio.h>
#include<conio.h>
main()
{
clrscr();
int a,b;
printf("\n Enter the value of a ");
scanf("%d",&a);
printf("\n Enter the value of b ");
scanf("%d",&b);
sum(a,b); //function with argument i.e. sum(a,b) called.
getch();
}

//function definition.

sum(int x, int y)
{
int z;
z=x+y;
printf("\n The value of sum is %d",z);
}


//Function with argument with return.


//This program has a function sum(a,b) used to pass the values only for calculation and return is used here.

//this function returns same value every time because the values are taken in main() function before called to sum(a,b).

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
clrscr();
printf("\n Enter the value of a ");
scanf("%d",&a);
printf("\n Enter the value of b ");
scanf("%d",&b);
c=sum(a,b); // The value is returned in variable c.
printf("\n The value of sum is %d",c);
getch();
}

//function definition.

sum(int x, int y)
{
int z;
z=x+y;
return(z);
}

Union in C Language

Union in C 

union:- 

A union is a user-defined data type in the C programming language that allows for the storage of elements of various data types, similar to a structure. However, in contrast to structures, all members of a C union occupy the same memory location. Consequently, at any given moment, only one member can hold data.

when union is declared the compiler automatically allocates enough memory storage to hold largest number. to access union directly we use dot(.) operator.to access union through pointer we use (->) operator. union conserve memory space, useful for applications involving multiple elements.

In union the integer(i) and character (ch) share the same memory location.

program to store 

#include<stdio.h>
#include<string.h>
union student;
{
char name[20];
int age;
};

main()
{
union student *s;
//*s means s is an array of undefined elements.
int i;
clrscr();
for(i=0;i<=2;i++)
{
printf("\n Enter the name: ");
fflush(stdin);
scanf("%s"&s[i].name);
printf("\n Enter the age: ");
scanf("%d",&s[i].age);
}

printf("\n Name Age");
printf("\n ----------------");
for(i=0;i<=2;i++)
{
printf("\n %s\t\t%d",s[i].name, s[i].age);
printf("\n ----------------");
}

getch();
}

Pointers in C Language

Pointer in C 

Pointer  

Pointers constitute a fundamental element of the C programming language. They serve the purpose of storing the memory addresses of various entities, including variables, functions, and even other pointers. The utilization of pointers facilitates low-level memory access, dynamic memory allocation, and a range of additional functionalities within C.A pointer variable points to a data type (like int) of the same type, and is created with the * operator.

syntax:-    type *name

Declaration:-    int *aoi;   

 //int is a type of pointer   

//*aoi is a pointer variable.


program to print the address of variable using unary operator.

#include<stdio.h>

#include<conio.h>

#include<string.h>

main()

{

int i,j;

float f;

char p[20];

clrscr();

i=50;

j=60;

printf("\n The value of i is= %d",i);

printf("\n The address of i is= %u",&i);

printf("\n The value of j is= %d",j);

printf("\n The address of j is= %u",&j);

getch();

}

//name pointer:- value of variable through address.

#include<stdio.h>

#include<conio.h>

#include<string.h>

main()

{

int i,j;

float f;

char name[20];

clrscr();

i=50;

j=60;

printf("\n The value i is= %d",i);

printf("\n The value i through address is= %d",*(&i));

printf("\n The address i is= %u",&i);

printf("\n The value j is= %d",j);

printf("\n The value j through address is= %d",*(&j));

printf("\n The address j is= %u",&j);

printf("\n The value float is= %f",dec);

printf("\n The value float through address is= %f",*(&dec));

printf("\n The address float dec is= %u",&dec);

printf("\n The value char name is= %s",name);

printf("\n The value of name through address is= %s",*(&name));

printf("\n The address char name is= %u",&name);

getch();

}


//program to create a pointer variable using your name and use it.

#include<stdio.h>

#include<conio.h>

main()

{

int i, *pankaj; //*pankaj store the address.

clrscr();

i=50;

pankaj=&i;

printf("\n The value of i is %d",&i);

printf("\n The value of i through addres is%d",*pankaj);

printf("\n The address of i is %u",pankaj);

*pankaj=*pankaj+20;

printf("\n the original value is %d",i);

printf("\n the updated value is %d"*pankaj);

getch();

}


//    pankaj shows the address of variable.

//    *pankaj shows the value of variable.

//    *pankaj+20 shows the updated value of variable.


//program to use pointer as an Array .


#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
int i,n, *roll;
//you can use *roll variable as pointer variable to store addrss.
// OR use it as array of undefinite element.
// here we use *roll as array not pointer.
clrscr();
printf("\n How many records you want to enter");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\n Enter the roll number= ");
scanf("%d",&roll[i]);
}
for(i=0;i<n;i++)
{
printf("\n The roll number is %d",roll[i]);
}
getch();
}


Note:- 

"&" (uniary operator)        //returns only one operand

m=&count;        //m has the address of count.

q=*m;        //q has the value of count.     //q recieves the value at address m.

Structures in C Language

 C Structures

Structure - structure is a collection of different data types.

program to create a structure and use them with structure variable. 

#include<stdio.h>
#include<string.h>
struct student
{
char name[20];
int age;
float per;
};
main()
{
struct student s1;
clrscr();
printf("\n Enter the name= ");
scanf("%c",&s1.name);
printf("\n Enter the age= ");
scanf("%d", &s1.age);
printf("\n Enter the per= ");
scanf("%f", &s1.per);
printf("\n The name is= %s",s1.name);
printf("\n The age is= %d",s1.age);
printf("\n The per is= %f",s1.per);
getch();
}

//structure keyword     : sturct
//sturctue name      : student
//structure variable     : s1
//structure member     : name, age, per
//structure presentation     : variable.member

program to create a structure and use them with two structure variable. 

#include<stdio.h>
#include<string.h>
struct student
{
char name[20];
int age;
float per;
};
main()
{
struct student s1,s2; //two structure variable
clrscr();
printf("\n Enter the name= ");
scanf("%c",&s1.name);
printf("\n Enter the age= ");
scanf("%d", &s1.age);
printf("\n Enter the per= ");
scanf("%f", &s1.per);
flush(stdin);
printf("\n Enter the name= ");
scanf("%c",&s2.name);
printf("\n Enter the age= ");
scanf("%d", &s2.age);
printf("\n Enter the per= ");
scanf("%f", &s2.per);
printf("\n The name is= %s",s1.name);
printf("\n The age is= %d",s1.age);
printf("\n The per is= %f",s1.per);
printf("\n The name is= %s",s2.name);
printf("\n The age is= %d",s2.age);
printf("\n The per is= %f",s2.per);
getch();
}
//structure keyword     : sturct
//sturctue naem     : student
//structure variable     : s1,s2
//structure member     : name, age, per
//structure presentation     : variable.member

program to create a Array of structure i.e. more than two structure variable using for loop.

//Array of structure i.e. more than two structure variabel using for loop.
#include<stdio.h>
#include<string.h>
struct student
{
char name[20];
int age;
};
main()
{
struct student s[3]; //structure array of 3
int i;
clrscr();
for(i=0;i<3;i++)
{
printf("\n Enter the name");
fulush(stdin);
scanf("%s",&s[i].name);
printf("\n Enter the age= ");
scanf("%d",s[i].age);
}
printf("\n Name Age ");
printf("\n ---------------------");
for (i=0;i<3;i++)
{
printf("\n %s %d",s[i].name, s[i].age);
}
printf("\n #####################");
getch();
}
//structure keyword     : sturct
//sturctue name     : student
//structure variable     : s[i]
//structure member     : name, age
//structure presentation     : variable array.member


Qus:- how to create structure with name, age and percent of a student, and how to create that structure variable to access the structure members?

Ans:-     struct student {char name[20]; int age, per}
student s;

Qus:- write down a structure of name, age, and percent and print two student details.

Ans:-     struct student {char name[20]; int age, per}
student s1,s2;

Qus:- write down a structure of name, age and percent and print 4 student details using structure array.

Ans:- struct student {char name[20]; int age, per}
student s[3];

Qus:- write down an union of name and age and then print them.
Ans:- *s (undefined length);

Strings in C Language

C Stings

program to print whole string. 

main()

{

char str[50];

clrscr();

printf(“Enter the string= ”);

gets(str); //(print the space also)

//scanf(str);         //(print only one string)

printf(“\n the string is = %s”, str);

getch();

}

//getch(); //(not show the output)

// alt+f5 to show the output.


program to print whole string with fflush function.

#include<stdio.h>

#include<string.h>

main()

{

char str[50];

int age;

clrscr();

printf(“\n enter the age= “);

scanf(“%d”, age);

printf(“\n enter the string= “);

fflush(stdin); //this function removes the garbage

gets(str);

printf(“\n the string is = %s”, str);

printf(“\n the age is = %d”, age);

getch();

}

program for print whole string character by character.

#include<stdio.h>

#include<string.h>

main()

{

char str[50];

int i;

clrscr();

printf(“\n Enter the string = ” );

flush(stdin); //remove the garbage

gets(str);

printf(“\n The String is= “);

for(i=0;i<49;i++)

{

Printf(“%c”,str[i]); //print character by character

 }

getch();

}

//Note : loop ke sath %c hi lagega.


program for print small to capital letter character by character.

#include<stdio.h>

#include<string.h>

main()

{

char str[50];

int i,l;

clrscr();

printf(“\n enter the string = ” );

flush(stdin); //remove the garbage

gets(str);

l=strlen(str); //count string length

printf(“\n the string is= “);

for(i=0;i<l;i++)

{

printf(“%c”,str[i]);         //print character by character

printf(“%c”,str[i]-32); //print in capital letters.

 }

getch();

}

//note : loop ke sath %c hi lagega.


program for print integer into character from 65 to 121.

//means a to z and a to z.
#include<stdio.h>
#include<string.h>
main()
{
int i;
clrscr();
for(i=65;i<122;i++)
{
printf(“# ** %c = %d ** #”, i, i);
}
getch();
}
//note : for show A to Z and also a to z. 

program for print small to capital  or capital to small.

#include<stdio.h>
#include<string.h>
main()
{
char str[50];
int i,l;
clrscr();
printf(“\n enter the string = ” );
flush(stdin);                     //remove the garbage
gets(str);
l=strlen(str);             //count string length
printf(“\n the string is= “);
for(i=0;i<l;i++)
{
if(str[i]>65 && str[i]<91)
{
printf(“%c”,str[i]+32);
}
else
{
printf(“%c”,str[i]-32);
}
//print character by character in capital letters.
 }
getch();
}

//note : loop ke sath %c hi lagega.

program to count vowel and consonants.

#include<stdio.h>
#include<string.h>
main()
{
char str[50];
int i, l, v=0, c=0;
clrscr();
printf("\n Enter the string= ");
flush(stdin);
gets(str);
l=strlen(str);
printf("\n the string is= ");
for(i=0;i<l;i++)
{
printf("%c",str[i]);
if(str[i]=='a' || str[i]=='e' || str[i]=='i' || str[i]='o' || str[i]=='u')
{v=v+i;} //count vovel
else
{c=c+i;} //count consonants
}
printf("\n The total vovels are= %d",v);
printf("\n the total consonants= %d",c);
getch();
}
//right button and show function details. (function directroy);

program to copy one string to another.


#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char str1[50], str2[50];
clrscr();
printf("\n Enter the string one");
gets(str1);
strcpy(str2,str1); //copy string1 into string2
printf("\n The string one is =%s",str1);
printf("\n The string two is =%s", str2);
getch();
}

program to copy one string to another string character by character using for loop.

#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char str1[50], str2[50];
int i, l;
clrscr();
printf("\n Enter the string one= ");
fflush(stdin);
gets(str1);
l=strlen(str1);
printf("\n The string one is= %s",str1);
printf("\n The string two is=");
for(i=0;i<l;i++)
{
str2[i]=str1[i];
printf("%c",str2[i]);
}
getch();
}

Saturday, September 28, 2024

C++ Interview Questions

 C++ Interview Questions

###Basic Concepts

1. Introduction to C++
Understanding C++ as an object-oriented programming language, its syntax, and structure.

2. Basic Syntax

    **Variables and Data Types:** int, float, char, double, bool.
    **Input/Output:** cin and  cout for user input and output.

3. Control Structures
    **Conditional Statements:**  if ,  else ,  switch.
    **Loops:**  for ,  while , do-while .

4. Functions
    **Function Declaration and Definition:** Creating reusable code.
    **Parameters and Return Types:** Passing arguments and returning values.

###Intermediate Concepts

5. Arrays and Strings
    **Arrays:** Fixed-size collections of elements.
    **Strings:** Using 'std::string' for text manipulation.

6. Pointers and References
    **Pointers:** Memory addresses, dereferencing, and pointer arithmetic.
    **References:** Aliases for existing variables.

7. Dynamic Memory Management
    **Dynamic Allocation:** Using 'new' and 'delete' for memory management.

8. Structs and Enums
   **Structs:** User-defined data types.
   **Enums:** Defining named integer constants.

9. Object-Oriented Programming (OOP)
    **Classes and Objects:** Defining classes and creating objects.
    **Encapsulation:** Using access specifiers ('public', 'private', 'protected').

### Advanced Concepts

10. Inheritance
    **Base and Derived Classes:** Extending classes to inherit properties.
    **Polymorphism:** Function overloading and overriding.

11. Abstract Classes and Interfaces
    **Pure Virtual Functions:** Creating abstract classes.

12. Templates
    **Function Templates:** Writing generic functions.
    **Class Templates:** Creating classes that can operate with any data type.

13. Exception Handling
    **Try-Catch Blocks:** Managing errors gracefully using exceptions.

14. Standard Template Library (STL)

   **Containers:** `vector`, `list`, `map`, `set`.
   **Algorithms:** Sorting, searching, and manipulation functions.

15. File I/O
   **Reading and Writing Files:** Using `fstream` for file operations.

### Specialized Concepts

16. Smart Pointers
    - **Unique and Shared Pointers:** Managing memory automatically.

17. Concurrency
    **Threads:** Creating and managing threads for concurrent programming.
    **Mutexes and Locks:** Synchronizing access to shared resources.

18. Move Semantics and Rvalue References
    **Understanding Move Constructors and Move Assignment Operators:** Efficient resource management.

19. Lambda Expressions
    **Using Lambda Functions:** Writing inline anonymous functions.

20. Design Patterns
    **Common Patterns:** Singleton, Factory, Observer, etc.

### Practical Application

21. Real-world Projects
   Building projects that incorporate various concepts learned, such as a simple game, file management system, or a data processing application.

22. Best Practices and Code Optimization
   Understanding coding standards, memory management, and performance optimization techniques.

C Language Interview Questions

C Language String Questions


Qus:- how to enter the string and print them.
Ans:- gets(str);

Qus:- how to enter the name and age and print them in full manner.
Ans:-    gets(str);

Qus:- 
how to enter the string and print them with for loop.
Ans:-    ("%c",str[i]);

Qus:- how to find the string length.
Ans:-    l=strlen(str);

Qus:- how to enter the string and print them in upper case.
Ans:-    ("%c",str[i]-32);

Qus:- how to convert integer to character. from 65 to 122 in c langugae?
Ans:-    printf(“# ** %c = %d ** #”, i, i);

Qus:- write a program for lower case to upper case and upper case to lower case.
Ans:-    if(str[i]>65 && str[i]<91) {printf(“%c”,str[i]+32);}
else {printf(“%c”,str[i]-32);}

Qus:- how to count the vovels and consonants in given string and print.
Ans:- for(i=0;i<l;i++) { printf("%c",str[i]);
if(str[i]=='a' || str[i]=='e' || str[i]=='i' || str[i]='o' || str[i]=='u')
{v=v+i;} //count vovel  else
{c=c+i;} //count consonants
}
Qus:- how to copy one string to another?
Ans:- scrcpy(str2, str1);

what is Java

Qus:- what is java?

Ans:- Java is a widely utilized programming language that was developed in 1995. It is currently owned by Oracle Corporation, and it operates on over 3 billion devices worldwide. Its applications include:
  • Mobile applications (specially Android apps)
  • Desktop applications
  • Web applications
  • Web servers and application servers
  • Games
  • Database connection
Java is compatible with various platforms, including Windows, Mac, Linux, and Raspberry Pi. It ranks among the most widely used programming languages globally and is currently in high demand within the job market. Its user-friendly nature makes it accessible for learners, and it is available as open-source software at no cost. Java is recognized for its security, speed, and robustness. The language benefits from extensive community support, comprising tens of millions of developers. As an object-oriented programming language, Java provides a clear framework for software development, facilitating code reuse and reducing overall development expenses. Additionally, its similarities to C++ and C# enable programmers to transition to Java or from Java to these languages with relative ease.

Advanced Java Interview Questions

Advanced Java Interview Questions-

  • what is database connectivity in java?
  • how is networking used in java?
  • what is servlet in java?
  • what is web services in java?
  • what is socket programming and how to use it in java?
  • how do you explain the multi tier architecture in java?
  • what is web client and web server?
  • what is web application? how do you explain it?
  • what is web container and what is use of it?
  • how do you explain session management in java?
  • what is JSP? also explain the JSP lifecycle.
  • what are the JSP Elements?
  • what is the JSP Tag library?
  • Explain the MVC? also define Type-1 and Type-2 architecture.
  • what is Struts framework?
  • what is Hibernate framework?
  • how do you describe Hibernate CRUD?
  • what is Spring framework?
  • what is Spring boot framework?

Friday, September 27, 2024

Core Java Interview Questions.

Core Java Interview Questions

  • ### Basic Questions
  • 1. **What is Java?**
  •    - A high-level, object-oriented programming language designed for portability and ease of use.

  • 2. **Explain the features of Java.**
  •    - Platform independence, object-oriented, robust, secure, and multithreaded.

  • 3. **What is the difference between JDK, JRE, and JVM?**
  •    - **JDK:** Java Development Kit (tools for development).
  •    - **JRE:** Java Runtime Environment (environment to run Java applications).
  •    - **JVM:** Java Virtual Machine (executes Java bytecode).

  • 4. **What are the primitive data types in Java?**
  •    - byte, short, int, long, float, double, char, boolean.

  • 5. **Explain the concept of variables and data types.**
  •    - Variables store data and have types that define the kind of data they hold.

  • ### Intermediate Questions

  • 6. **What is object-oriented programming (OOP)?**
  •    - A programming paradigm based on the concepts of objects and classes.

  • 7. **What are the four pillars of OOP?**
  •    - Encapsulation, inheritance, polymorphism, and abstraction.

  • 8. **What is the difference between method overloading and method overriding?**
  •    - **Overloading:** Same method name with different parameters in the same class.
  •    - **Overriding:** Redefining a method in a subclass with the same signature as in the superclass.

  • 9. **Explain the concept of inheritance.**
  •    - A mechanism where a new class (subclass) inherits properties and behaviors from an existing class (superclass).

  • 10. **What is an interface?**
  •     - A reference type in Java that can contain only constants, method signatures, default methods, static methods, and nested types. It cannot contain instance fields.

  • ### Advanced Questions

  • 11. **What are Java Collections?**
  •     - A framework that provides an architecture to store and manipulate a group of objects.

  • 12. **Explain the difference between List, Set, and Map.**
  •     - **List:** An ordered collection that allows duplicates (e.g., ArrayList).
  •     - **Set:** A collection that does not allow duplicates (e.g., HashSet).
  •     - **Map:** A collection of key-value pairs (e.g., HashMap).

  • 13. **What is exception handling?**
  •     - A mechanism to handle runtime errors, ensuring the normal flow of the application.

  • 14. **What is the difference between checked and unchecked exceptions?**
  •     - **Checked Exceptions:** Must be declared in a method’s throws clause (e.g., IOException).
  •     - **Unchecked Exceptions:** Do not need to be declared (e.g., NullPointerException).

  • 15. **What are Java Streams?**
  •     - A sequence of elements supporting sequential and parallel aggregate operations, introduced in Java 8.

  • ### Specialized Questions

  • 16. **What is multithreading?**
  •     - A programming concept that allows concurrent execution of two or more threads.

  • 17. **Explain synchronization in Java.**
  •     - A mechanism to control access to shared resources by multiple threads to prevent data inconsistency.

  • 18. **What is garbage collection in Java?**
  •     - The automatic process of reclaiming memory by destroying objects that are no longer in use.

  • 19. **What are lambda expressions?**
  •     - A feature introduced in Java 8 that allows you to implement functional interfaces in a concise way.

  • 20. **What is the Java Memory Model?**
  •     - A specification that describes how threads interact through memory and what behaviors are allowed in concurrent programming.

  • ### Expert Questions

  • 21. **What are design patterns? Name a few.**
  •     - Reusable solutions to common problems in software design (e.g., Singleton, Factory, Observer).

  • 22. **Explain the concept of reflection in Java.**
  •     - The ability to inspect and manipulate classes, methods, and fields at runtime.

  • 23. **What is the Java Virtual Machine (JVM) specification?**
  •     - A specification that provides an environment in which Java bytecode can be executed.

  • 24. **What are annotations in Java?**
  •     - Metadata that provides data about a program but is not part of the program itself.

  • 25. **How does Java handle memory management?**
  •     - Through automatic garbage collection and the stack/heap memory management model.

  • ### Practical Application

  • 26. **Code a simple Java program to demonstrate exception handling.**
  •     ```java
  •     public class ExceptionDemo {
  •         public static void main(String[] args) {
  •             try {
  •                 int division = 10 / 0;
  •             } catch (ArithmeticException e) {
  •                 System.out.println("Cannot divide by zero.");
  •             }
  •         }
  •     }
  •     ```

  • 27. **Implement a simple multithreading example.**
  •     ```java
  •     public class MyThread extends Thread {
  •         public void run() {
  •             System.out.println("Thread is running.");
  •         }
  •         public static void main(String[] args) {
  •             MyThread t1 = new MyThread();
  •             t1.start();
  •         }
  •     }
  •     ```

  • This structured approach will help you prepare effectively for Java interviews, covering foundational concepts to advanced topics.
  • what are the characteristics of java?
  • how to install and run java program?
  • how to run sample java program?
  • Explain the java class and methods in proper way?
  • what are the java comments and how you use them?
  • what are the java variables and how to declare it with syntax?
  • what is the final variable in java?
  • what are the print variables in java?
  • what is the java identifier?
  • what are the java primitive and non-primitive data types?
  • what is java type casting? also explain widening and narrowing casting.
  • what are the java operators? define the all types of operators.


  • what is java methods, how to create and call the methods in java?
  • what are the characteristics of java?
  • what are the parameters and arguments in java?
  • how can java return the values?
  • what is java method overloading?

Autonomous Vehicles

Autonomous Vehicles Autonomous vehicles are cars or trucks that can drive themselves without needing a human to control them. They use advan...