0% found this document useful (0 votes)
0 views

viva java

Uploaded by

hungryshockley1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

viva java

Uploaded by

hungryshockley1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Java is an object-oriented programming language that was developed by Sun

Microsystems (now owned by Oracle). Java is designed to be platform-independent,


meaning that Java code can run on any platform that has a Java Virtual Machine
(JVM). Java differs from other programming languages in several ways, including its
use of bytecode and its automatic memory management.

A class is a blueprint for creating objects, while an object is an instance of a


class. In other words, a class defines the attributes and methods that objects of
that class will have, while objects are specific instances of those attributes and
methods.

An interface in Java is a collection of abstract methods that define a contract for


the classes that implement it. Interfaces can be used to create loosely-coupled
systems, where different parts of the system can communicate with each other
through well-defined interfaces.

In Java, you declare a variable by specifying its data type and name, like this:
int myVariable;. Primitive data types in Java are types that represent basic types
of data, like integers, floating-point numbers, and booleans. Reference data types
in Java are types that refer to objects, like strings or arrays.

Access modifiers in Java are keywords that are used to control the visibility and
accessibility of classes, methods, and variables. The four access modifiers in Java
are public, private, protected, and package-private (also known as default).

An exception in Java is an error condition that occurs during the execution of a


program. In Java, you can handle exceptions using a try-catch block, where you
catch the exception and handle it in an appropriate way.

Inheritance in Java is a mechanism by which one class can inherit the properties
and methods of another class. Inheritance is used to create classes that are based
on existing classes, but with additional functionality or changes to the existing
functionality.

Polymorphism in Java is the ability of objects of different types to be treated as


if they are objects of the same type. Polymorphism can be achieved in Java through
method overriding or method overloading.

The "==" operator in Java tests for reference equality, while the .equals() method
tests for value equality. In other words, "==" checks if two objects are the same
object in memory, while .equals() checks if two objects have the same values.

An abstract class in Java is a class that cannot be instantiated, but can be


subclassed. An interface in Java is a collection of abstract methods that can be
implemented by any class. You would use an abstract class when you want to provide
a base implementation for a set of related classes, while an interface is used when
you want to define a set of methods that multiple classes can implement.

A static method in Java is a method that belongs to a class rather than to any
particular instance of the class. The main difference between a static method and
an instance method is that a static method can be called on the class itself, while
an instance method is called on an instance of the class.

Some common collections classes in Java include ArrayList, LinkedList, HashSet,


TreeSet, and HashMap. These classes differ in terms of how they store and
manipulate data, and which operations they support.

Multithreading in Java is the ability of a program to have multiple threads of


execution running concurrently. Multithreading can provide

You might also like