Sei sulla pagina 1di 20

C#

BASIC PREPERATION
What is difference between Java and
Android?

Java is one of the most popular object oriented programming


languages in the world. Java is heavily used for software and
web development. Recently, Java has become a popular
language for mobile-based applications as well.
Android is a mobile phone based platform developed by
Google.Android development is most of the times java-based
because a large portion of Java libraries is supported in Android.
However, there are key differences. Unlike Java, Android
applications do not have a main function. They have onCreate,
onResume, onPause and onDestroy functions that should be
overwritten by the developers. Java code compiles to Java
bytecode, while Android code compiles in to Davilk opcode.
What is difference between Java and C#?

C# JAVA

C# type safety is unsafe. Java type safety is safe

In C# mthods are not linked with the in Java methods can be defined only for
references types.Hence a data type the class reference types.
other than a reference type can define
methods in Java.
C# supports tuples Java does not support tupples.

C# offers supports for working with Java does not supports complex numbers
complex numbers.

C# supports weak reference types. Java supports weak references as well as


soft and phantom references

C# includes indexers a special case of Java does not support indexers instead
operator overloading supports getters and setters.
Write down the strong features of C#?

Boolean Conditions
Automatic Garbage Easy-to-use Generics
Collection Indexers
Standard Library Conditional Compilation
Assembly Versioning Simple Multithreading
Properties and Events LINQ and Lambda
Delegates and Events Expressions
Management Integration with Windows
Write down the strong features of JAVA?

Portable
Simple
Dynamic
Object-Oriented
Interpreted
Platform independent
High Performance
Secured
Multithreaded
Robust
Distributed
Architecture neutral
what is Object and Class in Java?

What is Object?
In real-world an entity that has state and its behavior is known as an object.
For Example:
A Car is an object. It has states (name, color, model ) and its behavior
(changing gear, applying brakes).
What is a class?
A class is a template or blueprint that is used to create objects.
Class representation of objects and the sets of operations that can be applied
to such objects.
Class consists of Data members and methods.
what are constructors in Java.
Constructors are special member functions whose task is to
initialize the objects of its class. It is treated as a special
member function because its name is the same as the class
name. Java constructors are invoked when their objects are
created.
Two Types of constructor
Default constructor (no-arg constructor)
Parameterized constructor
Java input and output classes

Stream
A stream can be defined as a sequence of data. There are
two kinds of Streams
InPutStream The InputStream is used to read data from
a source.
OutPutStream The OutputStream is used for writing
data to a destination.
Inheritance in java
Properties of a class can be joined in another class using
inheritance.
Note :- Multiple inheritance is not supported by java.
Child Class
Parent Class
The class in which properties of
The class whose properties are
parent class are inherited or
inherited.
accessed.
This class also called Super Class.
This class also called Sub Class.
Types of Inheritance
Types of inheritance supported by java are given below;

Single Inheritance
Multilevel Inheritance
Hybrid Inheritance
Types of Inheritance (1/4)
1) Single Inheritance
Single inheritanceis easy to understand. When a class
extends another one class only then we call it a single
inheritance. The below flow diagram shows that class B
extends only one class which is A. Here A is aparent classof
B and B would be achild classof A.
Types of Inheritance (2/4)
2) Multiple Inheritance
Multiple Inheritance refers to the concept of one class
extending (Or inherits) more than one base class. Following
flow diagram shows multiple inheritance.
Note :- Multiple Inheritance is not supported by java.
Types of Inheritance (3/4)
3) Multilevel Inheritance
Multilevel inheritancerefers to a mechanism in OO
technology where one can inherit from a derived class,
thereby making this derived class the base class for the new
class. In below flow diagram C is subclass or child class of B
and B is a child class of A.
Types of Inheritance (4/4)
4) Hybrid Inheritance
Hybrid inheritance is the combination of Single Inheritance
and Multiple Inheritance. I cant be directly supported by java,
we can achieve this by using interface. Hybrid inheritance can
be represented by the following diagram.
In this diagram, Class-A is the parent class of Class-B & Class-
C while Class-B and Class-C are parent classes of Class-D.
Java vs C# : Polymorphism
Abstraction in Java

Likewise in Object-oriented programming, abstraction is a


process of hiding the implementation details from the user,
only the functionality will be provided to the user.
Abstract Class
A class which contains theabstractkeyword in its
declaration is known as abstract class.
Abstraction in C#

In object-oriented software, complexity is managed by


usingabstraction.Abstractionis a process that involves
identifying the critical behavior of an object and eliminating
irrelevant and complex denials.
Example-A Laptop consists of many things such as
processor, motherboard, RAM, keyboard, LCD screen,
wireless antenna, web camera, USB ports, battery,speakers
etc. To use it, you don't need to know how internally LCD
screens, keyboard, web camera, battery, wireless antenna,
speakersworks. You just need to know how to operate the
laptop by switching it on.
Loops in Java
There may be a situation when you need to execute a block of code several
number of times. In general, statements are executed sequentially: The first
statement in a function is executed first, followed by the second, and so on.
Aloopstatement allows us to execute a statement or group of statements
multiple times and following is the general form of a loop statement in most of the
programming languages

Arrays in Java
Java provides a data structure, thearray, which stores a fixed-size sequential
collection of elements of the same type. An array is used to store a collection of
data, but it is often more useful to think of an array as a collection of variables of
the same type.
Instead of declaring individual variables, such as number0, number1, ..., and
number99, you declare one array variable such as numbers and use numbers[0],
numbers[1], and ..., numbers[99] to represent individual variables.
Loops in C#

There may be a situation, when you need to execute a block of code several
number of times. In general, the statements are executed sequentially: The first
statement in a function is executed first, followed by the second, and so on.
A loop statement allows us to execute a statement or a group of statements
multiple times and following is the general from of a loop statement in most of
the programming languages

Arrays in C#
Arraysworks as collections of items, for instance strings. You can use them
to gather items in a single group, and perform various operations on them,
e.g. sorting. Besides that, several methods within the framework work on
arrays, to make it possible to accept a range of items instead of just one.
This fact alone makes it important to know a bit aboutarrays.
Abstract method
Anabstract methodis amethodthat is declared, but
contains no implementation.Abstractclasses may not be
instantiated, and require subclasses to provide
implementations for theabstract methods.

Abstraction
Abstractionis the process ofabstraction in
Javais used to hide certain details and only show
the essential features of the object. In other words,
it deals with the outside view of an object.

Potrebbero piacerti anche