Posts

Showing posts with the label Gujarat Technological University

BE Semester 4 syllabus Download

Operating System - 3140702   Object Oriented Programming - I - 3140705 Computer Organization and Architecture - 3140707 Discrete Mathematics - 3140708 Principles of Economics and Management - 3140709

Practice Programs of Lab

Image
Program- 1 Write an application that defines a circle class with 2 constructors-the first form expects a double value that represents the radius of a circle, this constructor assumes that circle is centered at the origin. The second form accepts 3 double values, the first 2 arguments define the coordinates of the center and 3rd argument defines the radius. Also declare one member function, which calculates an area of the circle. Program 2 Create a program that defines a cube class with a constructor which accepts a double value that represent The length of edge of a cube and It will calculate the surface area and volume of that cube using the methods CubeArea and CubeVolume. Also make a display method which will display all the values related to that cube. Was that helpful? Let me know if it is.

Example Programs using Real world Classes and Objects

Image
this post contains example programs of real world classes and objects. Comments in these code will help you more to relate programs with real world conditions. It is advised to go through comments. In Last two examples you will notice that two output are almost same but the code of both of them is different. one of them uses constructor to initialize the class and other uses method to do the same work This comparision will help you to understand constructors 1. Example program of initializing Watch objects using constructors. 2. Program of initializing Car objects without using constructor 3. Program of Initializing Car objects using constructor You can also create many such programs just by getting the idea of real-world examples. If you don't know real world examples just go through my post. 10 real-world examples of classes Now create your own programs

Creating Objects

Image
As we have seen earlier a class provides the blueprint for objects. A class creates a logical framework that defines the relationship between its members. An object in Java is essentially a block of memory that contains space to store all the instance variables. It can also be considered as a variable. Obtaining objects of a class is a two-step process   Declaring  variable of the class type Acquiring an actual, physical copy of the object and assign it to that variable. Box mybox = new Box(); The above line creates an object of the Box class. Here it combines two statements into a single statement. It can be rewritten as - Box mybox; //declare reference to object mybox = new Box(); //allocate a box object Here, first line declares mybox as a reference to an object of type Box . After this line executes, mybox contains the value null. Any attempt to use mybox at this point may cause a compile-time error. S...

Introduction to classes with real-world Examples

10. Real world examples of classes, methods and Objects in Comparision with Object Oriented Programming A class is like a blueprint for creating similar objects. Let's take a real-world example A car company has a blueprint of any car model and based on that they create similar kind of cars. Here, every car is an object and the blueprint of car is like a class.  every car object has it's own attributes such as weight, color, seating capacity, etc. and methods such as driving, applying breaks, turning on headlights, etc. A class defines a new data type. Once defined, this new type can be used to create objects of that type. Means a class is a template for an object, and an object is an instance of an class. In other terms an Object is a specific case of a class. The General form of a class When we define a class we declare its exact form and nature. This is done by specifying the data that it contains and the code that operates...

Why my java programs are executing finely without using javac command?

I was having a question that why my programs are getting executed fine without using javac command which was told to use in my classroom lectures. I searched for it and got exact reason behind it. So I had a thought to share it with you friends. The main reason behind that is the version of java which I am using. I am having the latest version of java that is java SE 15.0.1  (Here is the step by step guide to install it) In all the versions earlier to java 11 you have to compile your code and then you can run it. here is the commands. javac Example.java java Example.java But if version of java is java 11 or later you can run java by itself to compile and auto-run your code. It will work well if your code is not having any error. java Example.java Now the question comes in mind that if we are able to run it just by using the java command then what is the use of javac ? I got the same, here is the answer The work of javac command is to compil...

Installing java and setting up environment variables

Image
Installing Java Before installing java Check whether java is already installed in your system or not. Step 1: Open the command prompt Step 2: type javac -version or java -version If it shows an error that means java is not installed in your system. Otherwise it will display the version of java installed in your system. Now comes the installation part Step 1. Open the browser and search for java SE or click here to directly go to site. There will be different versions of Java SE including Java SE 15,Java SE 14, etc. but I have downloaded Java 15 which is the latest version of java. Note: The installation which we have seen in class lecture was of JDK 8u111 . Step 2. Click on the JDK download option. Step 3. Click the appropriate JDK file according to your system's configuration. Check the checkbox and click on the download button. Let's say for my system I downloaded windows x64 installer. Step 4. Once it is downloaded Install It as you install all other software. Step 5. Afte...

Basic Unix commands

Image
If you are a windows user and haven't installed Ubuntu in your windows machine make sure you check out the guide on how to install ubuntu CLI in your system without virtual machine. Practice the basic commands of Linux/Unix. 1. Cal command Syntax: cal [options] [month] [year] Description: Cal displays a simple calendar. Output 2. Clear command Description: It clears the terminal screen. It clears your screen if this is possible, including its scroll back buffer. Clear ignores any command-line parameters that may be present. Syntax: clear Output 3. pwd: Displays the path of the present working directory. Syntax: pwd [options] Output 4. cd command Description:  It is used to change the directory. Used to navigate through different directories using Command line interface. .. is used with cd to go back to the previous directory. Syntax: cd [directory name] cd ~ is used to go t...

Encapsulation, Inheritance & Polymorphism - OOP principles

The three OOP principles Encapsulation Inheritance Polymorphism 1. Encapsulation ➡ The wrapping up of data and Methods into a single unit (called class) is known as E ncapsulation. It is also known as information hiding concept. The methods inside the class can only access the data present in that class. It is the mechanism that binds together code and the data it manipulates, and keeps both safe from outside interface and Misuse. Let's take a simple mobile phone. It is a complex electronic device , which is used for text and voice communication. The user of that mobile does not know the complexity of that mobile phone. He is no concerned about how it works. He is only concerned about is the fact that by pressing the green(answer) key, he can talk to the person on other side. Here user is isolated from all the the complex circuitry which is well encapsulated within the mobile phone. ➡ Methods i...

An overview of Java

The creation of Java It was developed by James Gosling, Patrick Naughton, Chris Warth, Ed Frank, and Mike Sheridan at Sun Microsystems. ➡ Initially named as Oak but then it was renamed "Java" in 1995. from Java coffee, the coffee from Indonesia. How Java changed the Internet It simplified the web programming, Java innovated a new type of networked program called Applet that changed the way the online world thought about content. Java solved the issues like  portability  and  security  associated with the internet. What is java Applets? An applet is a special kind of Java program that is designed to be transmitted over the Internet and automatically executed by a Java-compatible web browser. If the user clicks a link that contains an applet, the applet will be automatically downloaded and run in the browser. It allows some functionality to be moved from the server to the client. It is dynamic and self-exec...

Introduction to Java, classes and objects

Image
What is flow chart? ➡     A flowchart is a type of diagram that represents a workflow or process. Also It can be defined as a diagrammatic representation of  any process. Advantages of C language ➡ Speed of compilation is comparatively high ➡ Powerful and efficient language Problems with C programming ➡ It is a structured Programming Language ➡ C is middle level language ➡ Does not offers the concept of Object oriented programming ➡ We have to write too long code for simple programs ➡ It is complex to understand. ➡ It is also complex to code. Introduction to Java It is a programming language created by James Gosling from Sun Microsystems(SUN). It is object oriented programming language. Creator of java :- James Gosling Where Java can be used? ➡ Mobile applications ( mainly android apps) ➡ Desktop applications ➡ Web servers and application servers ➡ Web applications and much more.... Advantages of using Ja...

Basics of computer

Image
Basics of computer and memory What is machine level language? ➡     It is a low-level language comprised of binary digits(ones and  Zeros). what is High level language? ➡     Language designed to simplify computer programming. eg, C, C++. Basic computer architecture Founder of computer? Charles Babbage (1791-1871). First computer in the world ENIAC (Electronic Numerical Integrator and Computer) was the first electronic programmable computer built in U.S. ➡      Size of data variables depends on the type of compiler. Types of memory what is primary memory? ➡      volatile memory. vanishes up when the system is closed or when it is shut down. stores data temporarily. Secondary memory? ➡     Non volatile. eg, hard disk, SSD. stores data permanently. Cache memory?     It is extremely fast memory type. ...

YouTube