Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

SHOULD A MAIN() METHOD BE COMPULSORILY DECLARED IN ALL JAVA PROGRAMS?

Yes, without main method you can't execute class file, you'll get an runtime exception  as main
method missing.

WHAT IS THE RETURN TYPE OF MAIN()?

Java main method doesn't return anything, that's why it's return type is void.
WHY IS MAIN () METHOD DECLARED STATIC?
To make the main method accessible to operating system and to execute the main method
without creating the object.
WHAT IS THE ARGUMENT OF MAIN ()
JVM loads class with main method and pass String array, which contains arguments from command line.

DOES THE ORDER OF PUBLIC AND STATIC DECLARATION MATTER IN MAIN ()

It does not matter and we can have at any place. But void should come before main().

CAN A SOURCE FILE CONTAIN MORE THAN ONE CLASS DECLARATION?

Yes, it can. However, there can only be one public class per .java file, as public classes must have the
same name as the source file. One Java file can consist of multiple classes with the restriction that only
one of them can be public

WHAT IS MEANT BY ORIENTATION?

WHAT IS MEANT BY OBJECT ORIENTATION?

The perspective towards the instance of class called object orientation.

EXPLAIN A FEW KEY POINTS ASSOCIATED WITH AN OBJECT ORIENTED PROGRAMMING WITH RESPECT
TO THE REAL WORLD?

IS JAVA AN OBJECT ORIENTED PROGRAMMING?

Yes, But is not pure object oriented programming. So we use wrapping class to makes the java as pure
oop.

IS JAVA A PURE OBJECT ORIENTED PROGRAMMING?

Pure Object Oriented Language or Complete Object Oriented Language are Fully Object
Oriented Language which supports or have features which treats everything inside program as
objects. are seven qualities to be satisfied for a programming language to be pure Object
Oriented. They are:

1. Encapsulation/Data Hiding
2. Inheritance
3. Polymorphism
4. Abstraction
5. All predefined types are objects
6. All user defined types are objects
7. All operations performed on objects must be only through methods exposed at the
objects.

Java supports property 1, 2, 3, 4 and 6 but fails to support property 5 and 7 given above.

IS C++ AN OBJECT ORIENTATED PROGRAMMING?

C++ is usually considered a "multi-paradigm" language. It is certainly true that C++ isn't OO to the same
extent as Smalltalk, Ruby, Self, etc. are, but it is definitely an effective OO language by most standards

IS C AN OBJECT ORIENTATED PROGRAMMING?

No, C is not an 'object-oriented' language. It has no concept of classes, objects, polymorphism,


inheritance.

WHICH WAS THE FIRST OBJECT ORIENTED PROGRAMMING LANGUAGE?

Simula is generally accepted as being the first language with the primary features of an object-oriented
language

WHICH IS THE FIRST TRULY OBJECT ORIENTED PROGRAMMING LANGUAGE?

WHAT WAS THE STYLE OF PROGRAMMING WHICH WAS POPULARLY USED IN THE INDUSTRY BEFORE
OBJECT ORENTED STYLE CAME INTO EXISTENCE?

WHAT IS A CLASS?

Class is a blueprint (which is not existed).

WHAT IS AN OBJECT?

An object is an instance of class. An object has a state and behavior.

DO CLASSES HAVE PHYSICAL EXISTENCE?

No.

DO OBJECTS HAVE PHYSICAL EXISTENCE?

Yes, In world everything is an object.

WHAT IS MEANT BY PHYSICAL EXISTENCE?


BOTH C++ AND JAVA ARE OOPL, THEN WHY IS JAVA SO POPULARLY USED?

How are objects created in java?

All objects in Java programs are created on heap memory. An object is created based on its class. You
can consider a class as a blueprint, template, or a description how to create an object. When an object is
created, memory is allocated to hold the object properties.

WHO CREATES OBJECTS IN JAVA?

a class provides the blueprints for objects. So basically, an object is created from a class. In Java, the
new keyword is used to create new objects.

WHICH OPERATOR IS USED FOR OBJECT CRATION IN JAVA?

New.

HOW MANY OBJECTS OF A CLASS CAN BE CREATED?

Theoretically, there is no limit, you can create as many object as you want. Practically, there are some
limitations, number of objects that can be created depends on heap size.

COMMENT ON THE PROPERTIES OF AN OBJECT?

World is a collection of objects.

Every object belongs to a type and type in object orientation called class.

Every object is under constant interaction and no object is isolated.

Every object has something and does something

No object is uselss. Every object is usefull.

WHY IS OBJECT ORIENTATION A GOOD STYLE OF PROGRAMMING

OOPs represent a major shift from traditional procedural programming in which we use data and
functions. The data stored in variables and passed to defined function which in turn perform some
action and modify it or create new data. We can define the traditional procedural programming style as
a list of instructions which gets executed in an orderly manner defined by control flow statements and
functions.

WHEN DID THE IDEA OF OBJECT ORIENTATION EMERGE IN THE PROGRAMMING WORLD?

WHAT HAPPENS IF WE DO NOT DELCARE MAIN() AS PUBLIC?

If you don't declare main static a run-time error will occur saying please define the main method as
public.
WHAT HAPPENS IF WE DO NOT DELCARE MAIN() AS STATIC?

If you don't declare main static a run-time error will occur saying main() is not declared yet. a static
class cannot be instantiated. ... Because there is no instance variable, you access the members of a
static class by using the class name itself.

WHICH COMMAND IN JAVA IS USED TO INVOKE THE JAVA COMPIER?

javac

Which command IN JAVA ISUSED TO INVOKE THE JVM?

WHY SHOULD MAIN() MUST BE PRESENT IN ALL JAVA APPLICATIONS?

Every application execution starts with main().

WHAT ARE COMMAND LINE ARGUMENTS

HOW MANY COMMAND LINE ARGUMENTS CAN BE PASSED TO A JAVA PROGRAM

The arguments passed from the console can be received in the java program and it can be used as an
input. So, it provides a convenient way to check the behavior of the program for the different values.
You can pass N (1,2,3 and so on) numbers of arguments from the command prompt.

WHAT HAPPENS IF A JAVA PROGRAM EXPECTS COMMAND LINE ARGUMENTS BUT IS NOT SENT TO IT

WHY SHOULD AN OBJECT ALWAYS HAVE A HANDLE

WHAT IS A HANDLE ALSO CALLED AS

In Java, we can pass a reference to an object (also called a "handle")as a parameter. We can then
change something inside the object; we just can't change what object the handle refers to.

CAN WE HAVE MULTIPLE MAIN() METHODS WITHIN A SINGLE CLASS

es, you can have as many main methods as you like. You can have main methods with different
signatures from main(String[]) which is called overloading, and the JVM will ignore those main methods.
You can have one public static void main(String[] args) method in each class.

CAN WE HAVE MULTIPLE MAIN() METHODS IN A JAVA PROGRAM

You can have one public static void main(String[] args) method in each class. ... The only way to have
two main methods is by having two different classes each with one main method.

WHAT IS MEANT BY INSTANTIATION

Instantiation is the creation of a real instance or particular realization of an abstraction or template such
as a class of objects or a computer process. ... In other words, using Java, you instantiate a class to
create a specific class that is also an executable file you can run in a computer.

SHOULD A CLASS NAME BE A NOUN OR A VERB OR ADJECTIVE


Class names should be nouns or noun phrases. This means that the name of the class should be
something that would be the subject of a verb.

SHOULD A METHOD NAME BE A NOUN OR VERB OR ADJECTIVE

verb-like identifiers for methods. In your example, you could simply address the dilemma by using
"doMath" as the method name. That is a verb phrase.

SHOULD INTERFACE NAME BE A NOUN OR VERB OR ADJECTIVE

An interface is used like a class. Therefore, it should also be named with a noun when you name classes
with nouns

WHAT IS THE CAMEL CONVENTION FOR NAMING A VARIABLE?

Whenever we are writing the name of a variable all the letters should be small.

WHAT IS THE CAMEL CONVENTION FOR NAMING A METHOD?

Whenever we are writing the name of a method, first word first letter must be in lowercase. And
adjacent words first letter must be capital.

WHAT IS THE CAMEL CONVENTION FOR NAMING A CLASS?

Whenever we are writing the name of a class, first word first letter and adjacent words first letter should
be capital.

WHAT ARE THE DIFFERENT WAYS OF CREATING OBJECT IN JAVA

1. Using New keyword


2. Using new instance
3. Using clone() method.

WHAT IS AN ANONYMOUS OBJECT?

Whenever an object is instantiated but is not assigned to any reference variable, it is called anonymous
object.

WHEN IS USING ANONYMOUS OBJECT A GOOD APPROACH

An object which has no reference is known as an anonymous object. It can be used at the time of object
creation only. If you have to use an object only once, an anonymous object is a good approach.

WHAT IS THE ALTERNATIVE SYNTAX FOR MAIN()

Static public void main(String a[])

Public static void main(String …a)

WHAT IS THE BASIC REQUIREMENT THAT AN OPERATING SYSTEM EXPECTS FROM ANY PROGRAMMING
LANGUAGE
WHERE DOES THE EXECUTION OF A PROGRAM BEGIN FROM?

Program execution Starts and Ends at “main()” function. whenever the function is called then its
activation record is pushed into stack and keep on updating. when function completed its execution it
will be pop out of the stack.

WHY SHOULD THE MAIN() BE ENCLOSED WITH IN THE CLASS

We use 'static' because we don't create a object for the main class and we can use classname to call the
main function. Hence it is declared as static. Main method in java is a static method, therefore the class
it's in doesn't need to be instantiated into an object.

IS THERE ANY CONVENTION TO NAME A JAVA FILE?

Java naming convention is a rule to follow as you decide what to name your identifiers such as
class, If you fail to follow these conventions, it may generate confusion or erroneous code.
package, variable, constant, method, etc.

You might also like